I have the following setup:
Every document in ES has a field of type string, that contains a list
of
items
basket : ["yuca", "potato"]
and a field of type long called price
price: 626
I'm adjusting the score of my search results based on the difference
between
the price field and the price I search for.
I use CustomScoreQuery and I pass this mvel script to it:
floor(doc.price.value/100)
I am using a Boolean filter to get a partial match on the basket
field. I'm
using pyes (0.16.0), so under the hood the filter looks like this:
Here's what I'm trying to do:
I want to be able to adjust the score when I get a partial match on
the
basket field.
In this example I asked for 'yuca' and 'yam' and the result contains
'yuca'
and 'potato' (so only 'yuca' is a match). I want to penalise the score
by
one point for each missed term.
In this case the price contribution to the score is 6 and the basket
penalty
should be 1, so the overall score for this should be 5.
I prefer to handle this logic in the script that I pass to
CustomScoreQuery,
but I'm open to other solutions as well.
When you use should clauses in a bool query, the more matches you will have, the higher the score will be, so it should work for you.
On Wednesday, February 15, 2012 at 4:43 PM, Dragan wrote:
Hi,
I have the following setup:
Every document in ES has a field of type string, that contains a list
of
items
basket : ["yuca", "potato"]
and a field of type long called price
price: 626
I'm adjusting the score of my search results based on the difference
between
the price field and the price I search for.
I use CustomScoreQuery and I pass this mvel script to it:
floor(doc.price.value/100)
I am using a Boolean filter to get a partial match on the basket
field. I'm
using pyes (0.16.0), so under the hood the filter looks like this:
Here's what I'm trying to do:
I want to be able to adjust the score when I get a partial match on
the
basket field.
In this example I asked for 'yuca' and 'yam' and the result contains
'yuca'
and 'potato' (so only 'yuca' is a match). I want to penalise the score
by
one point for each missed term.
In this case the price contribution to the score is 6 and the basket
penalty
should be 1, so the overall score for this should be 5.
I prefer to handle this logic in the script that I pass to
CustomScoreQuery,
but I'm open to other solutions as well.
Thanks Shay, that works great when I want to see the results sorted by
score.
I'm trying to use score as a percentage match metric. Is there a way to set
the score based on the number of matches in the Boolean query? I'd like to
be able to tune the penalty function for imperfect matches.
On Wed, Feb 15, 2012 at 2:43 PM, Shay Banon kimchy@gmail.com wrote:
When you use should clauses in a bool query, the more matches you will
have, the higher the score will be, so it should work for you.
On Wednesday, February 15, 2012 at 4:43 PM, Dragan wrote:
Hi,
I have the following setup:
Every document in ES has a field of type string, that contains a list
of
items
basket : ["yuca", "potato"]
and a field of type long called price
price: 626
I'm adjusting the score of my search results based on the difference
between
the price field and the price I search for.
I use CustomScoreQuery and I pass this mvel script to it:
floor(doc.price.value/100)
I am using a Boolean filter to get a partial match on the basket
field. I'm
using pyes (0.16.0), so under the hood the filter looks like this:
Here's what I'm trying to do:
I want to be able to adjust the score when I get a partial match on
the
basket field.
In this example I asked for 'yuca' and 'yam' and the result contains
'yuca'
and 'potato' (so only 'yuca' is a match). I want to penalise the score
by
one point for each missed term.
In this case the price contribution to the score is 6 and the basket
penalty
should be 1, so the overall score for this should be 5.
I prefer to handle this logic in the script that I pass to
CustomScoreQuery,
but I'm open to other solutions as well.
On Thursday, February 16, 2012 at 12:21 AM, Dragan Chupacabrovic wrote:
Thanks Shay, that works great when I want to see the results sorted by score.
I'm trying to use score as a percentage match metric. Is there a way to set the score based on the number of matches in the Boolean query? I'd like to be able to tune the penalty function for imperfect matches.
When you use should clauses in a bool query, the more matches you will have, the higher the score will be, so it should work for you.
On Wednesday, February 15, 2012 at 4:43 PM, Dragan wrote:
Hi,
I have the following setup:
Every document in ES has a field of type string, that contains a list
of
items
basket : ["yuca", "potato"]
and a field of type long called price
price: 626
I'm adjusting the score of my search results based on the difference
between
the price field and the price I search for.
I use CustomScoreQuery and I pass this mvel script to it:
floor(doc.price.value/100)
I am using a Boolean filter to get a partial match on the basket
field. I'm
using pyes (0.16.0), so under the hood the filter looks like this:
Here's what I'm trying to do:
I want to be able to adjust the score when I get a partial match on
the
basket field.
In this example I asked for 'yuca' and 'yam' and the result contains
'yuca'
and 'potato' (so only 'yuca' is a match). I want to penalise the score
by
one point for each missed term.
In this case the price contribution to the score is 6 and the basket
penalty
should be 1, so the overall score for this should be 5.
I prefer to handle this logic in the script that I pass to
CustomScoreQuery,
but I'm open to other solutions as well.
On Thursday, February 16, 2012 at 12:21 AM, Dragan Chupacabrovic wrote:
Thanks Shay, that works great when I want to see the results sorted by score.
I'm trying to use score as a percentage match metric. Is there a way to set the score based on the number of matches in the Boolean query? I'd like to be able to tune the penalty function for imperfect matches.
When you use should clauses in a bool query, the more matches you will have, the higher the score will be, so it should work for you.
On Wednesday, February 15, 2012 at 4:43 PM, Dragan wrote:
Hi,
I have the following setup:
Every document in ES has a field of type string, that contains a list
of
items
basket : ["yuca", "potato"]
and a field of type long called price
price: 626
I'm adjusting the score of my search results based on the difference
between
the price field and the price I search for.
I use CustomScoreQuery and I pass this mvel script to it:
floor(doc.price.value/100)
I am using a Boolean filter to get a partial match on the basket
field. I'm
using pyes (0.16.0), so under the hood the filter looks like this:
Here's what I'm trying to do:
I want to be able to adjust the score when I get a partial match on
the
basket field.
In this example I asked for 'yuca' and 'yam' and the result contains
'yuca'
and 'potato' (so only 'yuca' is a match). I want to penalise the score
by
one point for each missed term.
In this case the price contribution to the score is 6 and the basket
penalty
should be 1, so the overall score for this should be 5.
I prefer to handle this logic in the script that I pass to
CustomScoreQuery,
but I'm open to other solutions as well.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.