Custom_filter_score in 0.19.4 is not working fine

I just tried with different score_mode in custom_filter_score, but its
always returning the same score, and its always including the default
scoring in the calculations, I just want to have the custom scoring to be
used and not the calculation based score........

On Thu, 2012-05-24 at 02:35 -0700, Narinder Kaur wrote:

I just tried with different score_mode in custom_filter_score, but
its always returning the same score, and its always including the
default scoring in the calculations, I just want to have the custom
scoring to be used and not the calculation based score........

Without a gist showing what you're doing, your report is not useful.

Please see Elastic Stack and Solutions Help · Forums and Slack | Elastic

ta

clint

{
"query": {
"custom_filters_score": {
"query": {
"match_all": {}
},
"filters": [
{
"filter": {
"range": {
"guid": {
"from": 0,
"to": 1000
}
}
},
"boost": "3"
},
{
"filter": {
"range": {
"guid": {
"from": 1001,
"to": 2000
}
}
},
"boost": "2"
}
],
"score_mode": "total"
}
}
}

the result is :

hits: [

  • {
    • _shard: 0
    • _node: kjfT2t0KTSulcTmlUKZEqA
    • _index: es_5
    • _type: IzapGeoCity
    • _id: 799
    • _score: 3
    • _source: {.....}
    • }]

and if I run this query :

{
"query": {
"custom_filters_score": {
"query": {
"term": {
"title": "india"
}
},
"filters": [
{
"filter": {
"range": {
"guid": {
"from": 0,
"to": 1000
}
}
},
"boost": "3"
},
{
"filter": {
"range": {
"guid": {
"from": 1001,
"to": 2000
}
}
},
"boost": "2"
}
],
"score_mode": "total"
}
}
}

the result is :

hits: [

  • {
    • _index: es_5
    • _type: IzapGeoCountry
    • _id: 683
    • _score: 26.04883
    • _source: {....
    • }
    • ]
  • here how the score can be 26.04883, when I am just assigning the
    values in custom_filter_score as "3" or "2".
  • so in case of score_mode:"total", the max score should be "5" and not
    26.04883.

surely, I know its including the default scoring in it for calculating the
total score, but I just want the score that I assigned.

and when i tried with different score_mode as "total", "first", "avg", in
all cases the max score is 26.04883

Please tell me the solution for this...

Thanks

On Thursday, 24 May 2012 15:09:13 UTC+5:30, Clinton Gormley wrote:

On Thu, 2012-05-24 at 02:35 -0700, Narinder Kaur wrote:

I just tried with different score_mode in custom_filter_score, but
its always returning the same score, and its always including the
default scoring in the calculations, I just want to have the custom
scoring to be used and not the calculation based score........

Without a gist showing what you're doing, your report is not useful.

Please see Elastic Stack and Solutions Help · Forums and Slack | Elastic

ta

clint

          * 
  * here how the score can be 26.04883, when  I am just assigning
    the values in custom_filter_score as "3" or "2".
  * so in case of score_mode:"total", the max score should be "5"
    and not 26.04883.

The custom_filters_score ALTERS your score, it doesn't override it
completely. So it is a useful way of (eg) boosting recent documents over
older documents while still retaining the 'relevance' factor.

You are doing a term QUERY, which means that ES looks to see how
relevant the term 'india' is, based on all the terms in your index.
That relevance score is then combined with your custom_filters boost to
produce a new value.

If you were to use a constant_score query with a term FILTER, or a
filtered query where the query is match_all, and your filter is the term
filter, then the _score from the query part would be 1 (plus your query
would be more efficient as you skip the relevance scoring step).

clint

But the same query was working fine with the earlier version of
0.18!!!!!!!!!!

why was then it overriding the relevance score????

On Thursday, 24 May 2012 16:21:48 UTC+5:30, Clinton Gormley wrote:

          * 
  * here how the score can be 26.04883, when  I am just assigning 
    the values in custom_filter_score as "3" or "2". 
  * so in case of score_mode:"total", the max score should be "5" 
    and not 26.04883. 

The custom_filters_score ALTERS your score, it doesn't override it
completely. So it is a useful way of (eg) boosting recent documents over
older documents while still retaining the 'relevance' factor.

You are doing a term QUERY, which means that ES looks to see how
relevant the term 'india' is, based on all the terms in your index.
That relevance score is then combined with your custom_filters boost to
produce a new value.

If you were to use a constant_score query with a term FILTER, or a
filtered query where the query is match_all, and your filter is the term
filter, then the _score from the query part would be 1 (plus your query
would be more efficient as you skip the relevance scoring step).

clint

On Thu, 2012-05-24 at 04:15 -0700, Narinder Kaur wrote:

But the same query was working fine with the earlier version of
0.18!!!!!!!!!!

why was then it overriding the relevance score????

Not correct. I've tried on 0.19.3 and 0.17.8 and I get the same result,
eg: gist:2781011 · GitHub

You might have thought that it was working in a different way, but I
don't see any difference between the two.

Just switch to using a term filter instead of a query, and it will work
the way you expect.

clint

I just got the issue solved, I tried the same query with the constant_score
query and now its working fine. thanks for the guidance, cause of your
comments, i could understand the logic behind this... thanks

On Thursday, 24 May 2012 17:27:58 UTC+5:30, Clinton Gormley wrote:

On Thu, 2012-05-24 at 04:15 -0700, Narinder Kaur wrote:

But the same query was working fine with the earlier version of
0.18!!!!!!!!!!

why was then it overriding the relevance score????

Not correct. I've tried on 0.19.3 and 0.17.8 and I get the same result,
eg: gist:2781011 · GitHub

You might have thought that it was working in a different way, but I
don't see any difference between the two.

Just switch to using a term filter instead of a query, and it will work
the way you expect.

clint