Uploaded image for project: 'Hibernate Search'
  1. HSEARCH-2221

Document in the migration guide that sort by Long @Id doesn't work anymore

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.6.0.Alpha3
    • Fix Version/s: 5.6.0.Beta2
    • Component/s: None
    • Labels:
      None
    • Environment:
      Win10x64, JDK 8
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

      Description

      I recently upgraded from 5.3.0.Final to 5.6.0.Alpha3, following the migration guide.

      As soon as I did I noticed that sorting HS queries by "id" field (id is the name of the property that I have annotated with @Id) simply fails silently. I.e., no exception is thrown, but results are not sorted by id. This property is of type Long, which means that the Lucene field is of type NUMERIC.

      I then saw the following warning emitted by Hibernate whenever I run my query:

      HSEARCH000289: Requested sort field(s) id are not configured for entity type com.fivoosh.entities.Applicant mapped to index com.fivoosh.entities.Applicant, thus an uninverting reader must be created. You should declare the missing sort fields using @SortableField.
      

      Ok, I added the @SortableField annotation and reindexed, then tried running the query again. This time I got an exception:

      Caused by: java.lang.IllegalStateException: unexpected docvalues type SORTED for field 'id' (expected=NUMERIC). Use UninvertingReader or index with docvalues.
      	at org.apache.lucene.index.DocValues.checkField(DocValues.java:208)
      	at org.apache.lucene.index.DocValues.getNumeric(DocValues.java:227)
      	at org.apache.lucene.search.FieldComparator$NumericComparator.getNumericDocValues(FieldComparator.java:167)
      	at org.apache.lucene.search.FieldComparator$NumericComparator.doSetNextReader(FieldComparator.java:153)
      	at org.apache.lucene.search.SimpleFieldComparator.getLeafComparator(SimpleFieldComparator.java:36)
      	at org.apache.lucene.search.FieldValueHitQueue.getComparators(FieldValueHitQueue.java:183)
      	at org.apache.lucene.search.TopFieldCollector$SimpleFieldCollector.getLeafCollector(TopFieldCollector.java:164)
      	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:812)
      	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:535)
      	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:523)
      	at org.hibernate.search.query.engine.impl.LazyQueryState.search(LazyQueryState.java:100)
      	at org.hibernate.search.query.engine.impl.QueryHits.updateTopDocs(QueryHits.java:241)
      	at org.hibernate.search.query.engine.impl.QueryHits.<init>(QueryHits.java:136)
      	at org.hibernate.search.query.engine.impl.LuceneHSQuery.getQueryHits(LuceneHSQuery.java:322)
      	at org.hibernate.search.query.engine.impl.LuceneHSQuery.queryEntityInfos(LuceneHSQuery.java:131)
      	at org.hibernate.search.query.hibernate.impl.FullTextQueryImpl.list(FullTextQueryImpl.java:200)
      	... 123 common frames omitted
      

      I tried changing the type in my SortField but alas - the SortField.Type enum doesn't contain a value named "SORTED".

        Attachments

          Activity

            People

            • Assignee:
              gsmet Guillaume Smet
              Reporter:
              annoraxx Ido Dovrat
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: