Custom Filter Score

Hello All

Good Evening

i prepare custom_filter_score query script

sample query
{
"timeout" : 60000,
"query" : {
"custom_filters_score" : {
"query" : {
"bool" : {
"should" : {
"query_string" : {
"query" : "kids",
"default_operator" : "or"
}
},
"minimum_should_match" : "1"
}
},
"filters" : [ {
"filter" : {
"numeric_range" : {
"payload.calculate" : {
"from" : "1",
"to" : "4",
"include_lower" : false,
"include_upper" : false
}
}
},
"script" : "scoringFieldValueList =
scoringFieldValue.split(delimiter); int i = 0; float _cscore = _score;
while(i <
scoringFieldValueList.size()){if(_source.payload.name.contains(scoringFieldValueList[i])){
_cscore = _cscore + 1.5; } i++; } _score=_cscore;"
}, {
"filter" : {
"numeric_range" : {
"payload.calculate" : {
"from" : "1",
"to" : "3",
"include_lower" : false,
"include_upper" : false
}
}
},
"script" : "scoringFieldValueList =
scoringFieldValue.split(delimiter); int i = 0; float _cscore = _score;
while(i <
scoringFieldValueList.size()){if(_source.payload.name.contains(scoringFieldValueList[i])){
_cscore = _cscore + 1.5; } i++; } _score=_cscore;"
} ],
"score_mode" : "total",
"params" : {
"delimiter" : ",",
"scoringFieldValue" : "American baby oil,American bandaid"
}
}
},
"explain" : false,
"fields" : [ "payload.contractName", "payload.code",
"payload.thing_type", "payload.name", "payload.description",
"payload.storefrontid" ]
}

es side throws the error

Caused by: [Error: unresolvable property or identifier: _score]
[Near : {float _cscore = _score;}]

please help me

Regards

Shanmugam.M

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi,
the custom filters score query is meant to give a weight to different
filters in order to influence the score of the main query when those
filters match. You can either specify a boost associated to each filter, or
a script. When using a script, you don't have the _score of the main query
available in the script, that's why you get that error.

On the other hand, the custom score query allows you to modify the score of
a query by providing a script, where you do have the _score of the query
itself available.

The point is that with the custom score query you have the main query and a
script that modifies its score, while with the custom filters score query
you have a main query and different filters that don't modify the score of
the main query but just influence it when matching. In fact the output of
the script in the custom filters score is still a weight, not the score
itself.

Hope this clarifies things for you

Cheers
Luca

On Thursday, July 25, 2013 4:20:06 PM UTC+2, shanmugam wrote:

Hello All

Good Evening

i prepare custom_filter_score query script

sample query
{
"timeout" : 60000,
"query" : {
"custom_filters_score" : {
"query" : {
"bool" : {
"should" : {
"query_string" : {
"query" : "kids",
"default_operator" : "or"
}
},
"minimum_should_match" : "1"
}
},
"filters" : [ {
"filter" : {
"numeric_range" : {
"payload.calculate" : {
"from" : "1",
"to" : "4",
"include_lower" : false,
"include_upper" : false
}
}
},
"script" : "scoringFieldValueList =
scoringFieldValue.split(delimiter); int i = 0; float _cscore = _score;
while(i <
scoringFieldValueList.size()){if(_source.payload.name.contains(scoringFieldValueList[i])){
_cscore = _cscore + 1.5; } i++; } _score=_cscore;"
}, {
"filter" : {
"numeric_range" : {
"payload.calculate" : {
"from" : "1",
"to" : "3",
"include_lower" : false,
"include_upper" : false
}
}
},
"script" : "scoringFieldValueList =
scoringFieldValue.split(delimiter); int i = 0; float _cscore = _score;
while(i <
scoringFieldValueList.size()){if(_source.payload.name.contains(scoringFieldValueList[i])){
_cscore = _cscore + 1.5; } i++; } _score=_cscore;"
} ],
"score_mode" : "total",
"params" : {
"delimiter" : ",",
"scoringFieldValue" : "American baby oil,American bandaid"
}
}
},
"explain" : false,
"fields" : [ "payload.contractName", "payload.code",
"payload.thing_type", "payload.name", "payload.description",
"payload.storefrontid" ]
}

es side throws the error

Caused by: [Error: unresolvable property or identifier: _score]
[Near : {float _cscore = _score;}]

please help me

Regards

Shanmugam.M

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks for ur reply

On Fri, Jul 26, 2013 at 3:28 PM, Luca Cavanna cavannaluca@gmail.com wrote:

Hi,
the custom filters score query is meant to give a weight to different
filters in order to influence the score of the main query when those
filters match. You can either specify a boost associated to each filter, or
a script. When using a script, you don't have the _score of the main query
available in the script, that's why you get that error.

On the other hand, the custom score query allows you to modify the score
of a query by providing a script, where you do have the _score of the query
itself available.

The point is that with the custom score query you have the main query and
a script that modifies its score, while with the custom filters score query
you have a main query and different filters that don't modify the score of
the main query but just influence it when matching. In fact the output of
the script in the custom filters score is still a weight, not the score
itself.

Hope this clarifies things for you

Cheers
Luca

On Thursday, July 25, 2013 4:20:06 PM UTC+2, shanmugam wrote:

Hello All

Good Evening

i prepare custom_filter_score query script

sample query
{
"timeout" : 60000,
"query" : {
"custom_filters_score" : {
"query" : {
"bool" : {
"should" : {
"query_string" : {
"query" : "kids",
"default_operator" : "or"
}
},
"minimum_should_match" : "1"
}
},
"filters" : [ {
"filter" : {
"numeric_range" : {
"payload.calculate" : {
"from" : "1",
"to" : "4",
"include_lower" : false,
"include_upper" : false
}
}
},
"script" : "scoringFieldValueList = scoringFieldValue.split(**delimiter);
int i = 0; float _cscore = _score; while(i < scoringFieldValueList.size()){
**if(_source.payload.name.**contains(**scoringFieldValueList[i])){
_cscore = _cscore + 1.5; } i++; } _score=_cscore;"
}, {
"filter" : {
"numeric_range" : {
"payload.calculate" : {
"from" : "1",
"to" : "3",
"include_lower" : false,
"include_upper" : false
}
}
},
"script" : "scoringFieldValueList = scoringFieldValue.split(**delimiter);
int i = 0; float _cscore = _score; while(i <
scoringFieldValueList.size()){**if(_source.payload.name.**contains(**scoringFieldValueList[i])){
_cscore = _cscore + 1.5; } i++; } _score=_cscore;"
} ],
"score_mode" : "total",
"params" : {
"delimiter" : ",",
"scoringFieldValue" : "American baby oil,American bandaid"
}
}
},
"explain" : false,
"fields" : [ "payload.contractName", "payload.code",
"payload.thing_type", "payload.name", "payload.description",
"payload.storefrontid" ]
}

es side throws the error

Caused by: [Error: unresolvable property or identifier: _score]
[Near : {float _cscore = _score;}]

please help me

Regards

Shanmugam.M

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards

Shanmugam.M

--
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.
For more options, visit https://groups.google.com/groups/opt_out.