Hello,
I am trying to implement case-insensitive sorting using Hibernate Search for a couple of text-based fields.
Lucene out-of-the-box, using the following sort type:
Code:
org.apache.lucene.search.SortField.STRING
Defaults to case-sensitive sorting. I read the Lucene documentation, and have gone down the path of extending the Lucene class:
Code:
org.apache.lucene.search.SortComparator
This worked for one field, but not the other. The first field sorts great in a case-INsensitive manner. The second field, however, gives me a stack trace at search time:
Code:
java.lang.NullPointerException
at org.apache.lucene.search.SortComparator$1.compare(SortComparator.java:54)
at org.apache.lucene.search.FieldSortedHitQueue.lessThan(FieldSortedHitQueue.java:125)
at org.apache.lucene.util.PriorityQueue.insertWithOverflow(PriorityQueue.java:80)
at org.apache.lucene.search.FieldSortedHitQueue.insertWithOverflow(FieldSortedHitQueue.java:108)
at org.apache.lucene.search.TopFieldDocCollector.collect(TopFieldDocCollector.java:61)
at org.apache.lucene.search.BooleanScorer2.score(BooleanScorer2.java:320)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:146)
at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:124)
at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:100)
at org.apache.lucene.search.Hits.<init>(Hits.java:77)
at org.apache.lucene.search.Searcher.search(Searcher.java:64)
at org.hibernate.search.query.FullTextQueryImpl.getHits(FullTextQueryImpl.java:270)
at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:232)
at com.connect.vine.search.SearchManagerImpl.searchProductsWithMultiCriteria(SearchManagerImpl.java:193)
The line that is failing is this in
SortComparator.java:
Code:
public int compare (ScoreDoc i, ScoreDoc j) {
return cachedValues[i.doc].compareTo (cachedValues[j.doc]); // cachedValues is null at either i.doc or j.doc
}
Before I go into depth of how I've configured Hibernate Search and my code... I'm just wondering - am I going down the right path of using Lucene's
SortComparator? Or, is there a simpler way of doing case-insensitive sorting using Hibernate Search?
I have been struggling with this for almost a week now, but still no progress.
Thank you very much!
-Frank
Hibernate Search version: 3.0.1.GA
Lucene version: 2.3.1
Hibernate version: 3.2.6.ga
Hibernate Annotations version: 3.3.0.ga
Hibernate commons-annotations version: 3.3.0.ga
Name and version of the database you are using: Oracle