开发者

How to sort Search Results based on a Field Value in Lucene-3.0.2?

开发者 https://www.devze.com 2023-01-06 18:26 出处:网络
I have g开发者_如何学Gooogled a lot and also searched in stackoverflow.com about how to sort search results based on a Field Value in Lucene 3.0.2, but not found any useful data. I\'m getting the sear

I have g开发者_如何学Gooogled a lot and also searched in stackoverflow.com about how to sort search results based on a Field Value in Lucene 3.0.2, but not found any useful data. I'm getting the search results from the index, based on the user query but not able to sort the results based on field like id or date.

I have pasted my code here for searching lucene index- http://pastie.org/1033974.

Please help me to solve this problem. If you provide me some example code or links where i can find that will be better.

Thanks


The IndexSearcher class has a couple of search methods that takes a Sort Object that you have to use. A Sort object is basically a wrapper around one or more SortField objects which hold details on what field to sort on and how.

Note that a field must be indexed to be used for sorting.

0

精彩评论

暂无评论...
验证码 换一张
取 消