Sorting search hits based on an attribute value

Hello All,

I want to sort the search hits based on two criteria - (1) value of an
attribute, and (2) _score. The first criteria is such that if the attribute
has two values "open" and "closed", the search hits with value "open"
should be ranked above those with value "closed". What is the best way to
do this in ES?

One approach I tried was to invert the score for search hits with value
"closed" using a function_score query. Though this works, there are two
issues - (1) search hits with value "closed" are ranked in the reverse
order of their score, (2) this approach does not allow handling more than
two values of the attribute. Is there a better way to do this in ES?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5221fb7b-25bc-4065-9500-ad7f3bf2655e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi ,

I feel you should write a script and use that in the function_score.

So assuming _score is normalized to a value between 0 and 1.

value of closed = 1
value of open = 2

Score of a document = value of attribute + _score.

Thanks
Vineeth

On Wed, Jul 2, 2014 at 9:27 AM, bsa shashi.b.anand@gmail.com wrote:

Hello All,

I want to sort the search hits based on two criteria - (1) value of an
attribute, and (2) _score. The first criteria is such that if the attribute
has two values "open" and "closed", the search hits with value "open"
should be ranked above those with value "closed". What is the best way to
do this in ES?

One approach I tried was to invert the score for search hits with value
"closed" using a function_score query. Though this works, there are two
issues - (1) search hits with value "closed" are ranked in the reverse
order of their score, (2) this approach does not allow handling more than
two values of the attribute. Is there a better way to do this in ES?

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/5221fb7b-25bc-4065-9500-ad7f3bf2655e%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/5221fb7b-25bc-4065-9500-ad7f3bf2655e%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGdPd5k_2JwxncZd_yfF4Cw2N9d7mnBWfSHDbQ24pCTRz_C8Cg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.