My requirement is if user searches the 'Page number' using Lucene search, Search results should take care of matching the Page number in the result with Exact Page number match on top of the list.
Now in my case I tried to sort using SortField -
new Sort(new SortField("bookPageNumber", SortField.STRING));
Suppose I searched term '5' then in the search result instead of showing Exact Page number match on top of the list it shows searched term '5' which is present at each page.
Can anyone suggest how to include Page Number in Lucene Search results on top of the list.
My code -
QueryParser qParser;
qParser = new QueryParser("contents", new StandardAnalyzer(Version.LUCENE_CURRENT));
qParser.setDefaultOperator(QueryParser.Operator.AND);
String searchResultMaxCount = "10";
int maxCount = Integer.parseInt(searchResultMaxCount);
Query query = qParser.parse("5");
Sort sort = new Sort(new SortField("bookPageNumber", SortField.STRING));
TopDocs topDocs = indexSearcher.search(query, null, maxCount, sort);