tags:

views:

160

answers:

1

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?

A: 

You could use querytime boosting:

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

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

Dominik
And what will be with scoring formula in this case? "basequery" will have normal boost and best will have enormous boost. So can happen the situation when user will search for "I love lucene" in "contents" field and will find irrelevant results like "Ann loves her mom", "I love 1 april" becase they have "the best" in enum field and relevant result "I love lucene" will be in bottom because this result have no enum field.
Jeriho