title: Sortiing String field alphabetically in Lucene 5.0
body: <p>I'm having issues sorting on string fields in Lucene 5.0. Apparantly the way you could sort since Lucene 4 has changed. Below shows a snippet of some of the fields that are being index for my documents.</p>
  
  <pre><code>@Override
  public Document generateDocument(Process entity)
  {
      Document doc = new Document();
      doc.add(new IntField(id, entity.getID(), Field.Store.YES));
      doc.add(new TextField(title, entity.getProcessName(), Field.Store.YES));
      doc.add(new IntField(organizationID, entity.getOrganizationID(), Field.Store.YES));
      doc.add(new StringField(versionDate, DateTools.dateToString(entity.getVersionDate(), DateTools.Resolution.SECOND), Field.Store.YES));
      doc.add(new LongField(entityDate, entity.getVersionDate().getTime(), Field.Store.YES)); 
      return doc;
  }
  </code></pre>
  
  <p>I would like to sort on relevance first, which works just fine. The issue I have is that sorting on the title field doesn't work. I've created a sortfield which i'm trying to use with a TopFieldCollector after a chain of method calls.</p>
  
  <pre><code>public BaseSearchCore&lt;Process, ProcessSearchResultScore&gt;.SearchContainer search(String searchQuery, Filter filter, int page, int hitsPerPage) throws IOException, ParseException
      {
      SortField titleSort = new SortField(title, SortField.Type.STRING, true);
      return super.search(searchQuery, filter, page, hitsPerPage, title);
      }
  </code></pre>
  
  <p>Which goes to:</p>
  
  <pre><code>public SearchContainer search(String searchQuery, Filter filter, int page, int hitsPerPage, SortField... sortfields) throws IOException, ParseException 
      {
          Query query = getQuery(searchQuery);
          TopFieldCollector paginate = getCollector(sortfields);
          int startIndex = (page -1) * hitsPerPage;
          ScoreDoc[] hits = executeSearch(query, paginate, filter, startIndex, hitsPerPage);
  
          return collectResults(query, filter, hitsPerPage, hits, page);
    }
  </code></pre>
  
  <p>And finally to the method that applies the sort field:</p>
  
  <pre><code>private TopFieldCollector getCollector(SortField sortfield) throws IOException
      {
          SortField[] sortFields = new SortField[] {SortField.FIELD_SCORE, sortField};
          Sort sorter = new Sort(sortFields);
          TopFieldCollector collector = TopFieldCollector.create(sorter, 25000, true, false, true);
          return collector;
      }
  </code></pre>
  
  <p>Using the returned collector a regular query is performed, and a result is returned. However, if I try to sort with this SortField i'll get this exception:</p>
  
  <p>java.lang.IllegalStateException: unexpected docvalues type NONE for field 'title' (expected=SORTED). Use UninvertingReader or index with docvalues.</p>
  
  <p>How am I supposed to index a string field to be able to sort it alphabetically(using sortfields) in Lucene 5? Any code examples or snippets would be much appriciated.</p>
  
  <p>Searching by relevancy works just fine, but when users enter empty search queries all the results have the same relevancy. With those queries I'd rather sort by the results titles, which is causing issues in this iteration of Lucene.</p>