Hibernate search version : hibernate-search-3.1.0.Beta1
Lucene: lucene-core-2.3.2.jar
Hi,
I am a newbie.
I just configured lucene using hibernate search. But I find that the sorting does NOT ignore null values.
I am searching using one field, say X and want to sort the results using another, say Y (Which can have null values). But I am expecting Sort to ignore all the null values and just sort only records that has values in Y field.
How can I achieve this. Is there anywhere I can set the flag in SortField that specifies it to ignore all the null values ?
Please help.
Code:
FullTextSession fullTextSession = Search.getFullTextSession(session);
QueryParser parser = new MultiFieldQueryParser(new String[]{"keywords", "title"}, new StandardAnalyzer());
Query query = parser.parse(keywordText);
FullTextQuery hibernateQueryObj = fullTextSession.createFullTextQuery(query, SearchObject.class);
Sort sortCriteria = new Sort(new SortField("lastUpdatedDate",
SortField.STRING,
true));
hibernateQueryObj.setSort(sortCriteria);
hibernateQueryObj.setFirstResult(0);
In the above code "lastUpdatedDate" can be null value. But I don't want null to be considered by my Sort .
thanks