Manually adjusting document sort based on queries

For specific queries I want to be able to manually set the sort of some
search results. Without going into the reason why, how do I implement this?
I'm not talking about boosting, I'm talking about manually setting the sort
position based on specific query.

E.g. if users searches for "Green Military Shirts" I want to set product X
to position 1, product J to position 2. All other search results would
sorted as usual.

--
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/2757e0a1-ca5a-498e-89e2-02cf3dad9e0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

It appears I've answered my own question unless someone has a better
suggestion in terms of efficiency and logic. The function_score Query
(http://www.elastic.co/guide/en/elasticsearch/guide/master/function-score-query.html)
will allow for boosting specific documents based on the query. Several
different predefined methods or I can create my own custom script.

On Saturday, March 21, 2015 at 10:38:54 AM UTC-7, Zelfapp wrote:

For specific queries I want to be able to manually set the sort of some
search results. Without going into the reason why, how do I implement this?
I'm not talking about boosting, I'm talking about manually setting the sort
position based on specific query.

E.g. if users searches for "Green Military Shirts" I want to set product X
to position 1, product J to position 2. All other search results would
sorted as usual.

--
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/fb45a9a8-076a-4d9c-af62-887ce3508382%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Easiest option, in terms of complexity, would probably be to use a bool
query, where product x and y are matched by an id query with high boosts.

Best option is probably the function score query:
http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

Create a filter for each product and replace the score with something
arbitrarly high.

You could get detailed by using a custom script, but it will not be as
efficient.

Cheers,

Ivan
On Mar 21, 2015 7:39 PM, "Zelfapp" nate@usamm.com wrote:

For specific queries I want to be able to manually set the sort of some
search results. Without going into the reason why, how do I implement this?
I'm not talking about boosting, I'm talking about manually setting the sort
position based on specific query.

E.g. if users searches for "Green Military Shirts" I want to set product X
to position 1, product J to position 2. All other search results would
sorted as usual.

--
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/2757e0a1-ca5a-498e-89e2-02cf3dad9e0e%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/2757e0a1-ca5a-498e-89e2-02cf3dad9e0e%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/CALY%3DcQCibunCj15nHP0vNm8gg0U7qukDL%3DUKrmahx-OR9KLhjQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.