Boost query by another field


(slushi) #1

I would like to boost a query based on whether a separate field of the
document contains the query term. This is similar to a bool query with
must/should clauses except I would like the clauses' scores to be
multiplied rather than added. Basically, I would like the score to be
mainly based on the main query, but just slightly modified based on the
separate field. If I do a bool query, it seems as though there is a fairly
good chance that in certain cases the 'should' clause on the separate field
could play too large or too small a role during scoring.

--
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/32858b81-9d7c-4e70-9490-d15d55bb5724%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Alexander Reelsen) #2

Hey

check out the function score query and its score mode:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

--Alex

On Fri, Dec 6, 2013 at 1:12 AM, slushi kireetreddy@gmail.com wrote:

I would like to boost a query based on whether a separate field of the
document contains the query term. This is similar to a bool query with
must/should clauses except I would like the clauses' scores to be
multiplied rather than added. Basically, I would like the score to be
mainly based on the main query, but just slightly modified based on the
separate field. If I do a bool query, it seems as though there is a fairly
good chance that in certain cases the 'should' clause on the separate field
could play too large or too small a role during scoring.

--
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/32858b81-9d7c-4e70-9490-d15d55bb5724%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/CAGCwEM_3nhtxppf%2BTp2BMxVDv8Ozk5WF%2BsCz5n14W2hHQmN_zw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(slushi) #3

How would that work? I would need to see if the analyzed query term(s) hit the document field. I can see the function score working if the boost factor is pre-computed and captured in a numerical field, but that isn't what I am trying to do here.

On Dec 6, 2013, at 2:58 AM, Alexander Reelsen wrote:

Hey

check out the function score query and its score mode: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

--Alex

On Fri, Dec 6, 2013 at 1:12 AM, slushi kireetreddy@gmail.com wrote:
I would like to boost a query based on whether a separate field of the document contains the query term. This is similar to a bool query with must/should clauses except I would like the clauses' scores to be multiplied rather than added. Basically, I would like the score to be mainly based on the main query, but just slightly modified based on the separate field. If I do a bool query, it seems as though there is a fairly good chance that in certain cases the 'should' clause on the separate field could play too large or too small a role during scoring.

--
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/32858b81-9d7c-4e70-9490-d15d55bb5724%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/zyHZOO_l8PA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_3nhtxppf%2BTp2BMxVDv8Ozk5WF%2BsCz5n14W2hHQmN_zw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/10FCD9FC-4AF4-49BF-8D94-93E8D2923E47%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Nik Everett) #4

On Thu, Dec 5, 2013 at 7:12 PM, slushi kireetreddy@gmail.com wrote:

Basically, I would like the score to be mainly based on the main query,
but just slightly modified based on the separate field. If I do a bool
query, it seems as though there is a fairly good chance that in certain
cases the 'should' clause on the separate field could play too large or too
small a role during scoring.

This text makes the Boosting Query (
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html)
sound like the best choice or a bool query with very different boosts on
the clauses. Those both basically add the scaled scores together. Like
this: score = score_1 * 10 + score_2.

I don't believe there is a query type that scores by multiplying results,
though. I mean, one like this: score = score_1 * score_2. I'm not sure
the exact use case for such a thing, though.

--
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/CAPmjWd0sezE86uPQV52HSwsp9gWieRfcFMfQEvnWkjHOkEW-Xw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(slushi) #5

The use case is as follows: I have several documents with a full text field
as well as metadata fields (title, tags, etc). It seems to me that the main
driver of relevance should be the full text field, but if a metadata field
also matches, I would like to experiment with boosting the score. The issue
with adding scores is that the metadata field clause could contribute too
much or too little to the final score. instead i would like to do something
like "score the query against the full text field and if it also matches a
metadata field, boost the score by 10%".

On Friday, December 6, 2013 11:27:21 AM UTC-5, Nikolas Everett wrote:

On Thu, Dec 5, 2013 at 7:12 PM, slushi <kiree...@gmail.com <javascript:>>wrote:

Basically, I would like the score to be mainly based on the main query,
but just slightly modified based on the separate field. If I do a bool
query, it seems as though there is a fairly good chance that in certain
cases the 'should' clause on the separate field could play too large or too
small a role during scoring.

This text makes the Boosting Query (
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html)
sound like the best choice or a bool query with very different boosts on
the clauses. Those both basically add the scaled scores together. Like
this: score = score_1 * 10 + score_2.

I don't believe there is a query type that scores by multiplying results,
though. I mean, one like this: score = score_1 * score_2. I'm not sure
the exact use case for such a thing, though.

--
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/834f4fbb-85f2-416c-bb4d-37bb140d2703%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Nik Everett) #6

Have a look at
http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/query-dsl-function-score-query.html#_relation_to_literal_custom_boost_literal_literal_custom_score_literal_and_literal_custom_filters_score_literal.
Check the "and the Custom
Filters Score Queryhttp://www.elasticsearch.org/guide/en/elasticsearch/reference/master/query-dsl-custom-filters-score-query.html"
part. That might have what you want.

On Fri, Dec 6, 2013 at 1:00 PM, slushi kireetreddy@gmail.com wrote:

The use case is as follows: I have several documents with a full text
field as well as metadata fields (title, tags, etc). It seems to me that
the main driver of relevance should be the full text field, but if a
metadata field also matches, I would like to experiment with boosting the
score. The issue with adding scores is that the metadata field clause could
contribute too much or too little to the final score. instead i would like
to do something like "score the query against the full text field and if it
also matches a metadata field, boost the score by 10%".

On Friday, December 6, 2013 11:27:21 AM UTC-5, Nikolas Everett wrote:

On Thu, Dec 5, 2013 at 7:12 PM, slushi kiree...@gmail.com wrote:

Basically, I would like the score to be mainly based on the main query,
but just slightly modified based on the separate field. If I do a bool
query, it seems as though there is a fairly good chance that in certain
cases the 'should' clause on the separate field could play too large or too
small a role during scoring.

This text makes the Boosting Query (http://www.elasticsearch.org/
guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html)
sound like the best choice or a bool query with very different boosts on
the clauses. Those both basically add the scaled scores together. Like
this: score = score_1 * 10 + score_2.

I don't believe there is a query type that scores by multiplying results,
though. I mean, one like this: score = score_1 * score_2. I'm not sure
the exact use case for such a thing, though.

--
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/834f4fbb-85f2-416c-bb4d-37bb140d2703%40googlegroups.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
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/CAPmjWd0j7xVoP62M_Y8QAELpbVf-tcMp_CVc_HqVpAnjTqo40A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #7