I want to list the lastest 10 rows order by id DESC
Sort sort = new Sort(new SortField[]{new SortField("id",SortField.INT,true)});
TopDocs topDocs=indexSearch.search(null,null,10,sort);//no need Query,only sort
...
I got a 500 exception because the Query parameter is null
How can I implement it in a best way?
btw:id field is a NumericField,write using:
new NumericField("id",Integer.MAX_VALUE,Field.Store.YES,true)
You should use the
MatchAllDocsQueryfor that.Lucene Query is a peculiar object that isn’t only the specification of the query semantics, but also the implementation of the most efficient execution strategy for each particular query type. That’s why there must be a special Query even for this “no-op”