开发者

How to sort search results in lucene?

开发者 https://www.devze.com 2022-12-26 15:29 出处:网络
For example, if I have enumeration with \"good\", \"better\", \"the best\" values, I want to sort my search results by field that holds one of this values in string representation.

For example, if I have enumeration with "good", "better", "the best" values, I want to sort my search results by field that holds one of this values in string representation.

I have few purposes:

1) Create CustomAnalyzer that produces numeric value from enum: good -> 1, better -> 2, the best -> 3

2) Implement FieldComparator (I don't know how)

开发者_开发知识库Any ideas?


You could use querytime boosting:

+(basequery) best^10000 better^100 good^10

See also, http://wiki.apache.org/solr/SolrRelevancyCookbook#Boosting_Ranking_Terms

0

精彩评论

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

关注公众号