tags:

views:

96

answers:

1

Hi,

I have googled 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

+4  A: 

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.

Pascal Dimassimo
Thanks Pascal Dimassimo..!!! I will see, how i can work around with those..!!!
techiepark