Closed peterdm closed 7 years ago
@peterdm
A script
query doesn't actually return a score (it always returns 1 or a 0). I think this is similar to the other issue we discussed. A function_score_query
appears to work
GET /test/empty/_search?explain=true
{
"query": {
"match_all": {}
},
"script_fields": {
"days_between": {
"script": {
"params": {
"search_timestamp": "2017-03-23T00:00:00.000Z",
"compare_to": "2017-03-18T04:34:15.606Z"
},
"lang": "painless",
"inline": "return ChronoUnit.DAYS.between(Instant.parse(params.compare_to), Instant.parse(params.search_timestamp))"
}
}
},
"rescore": {
"query": {
"rescore_query": {
"ltr": {
"model": {
"stored": "dummy"
},
"features": [
{
"function_score": {
"_name": "days_between",
"functions": [
{
"script_score": {
"script": {
"params": {
"search_timestamp": "2017-03-23T00:00:00.000Z",
"compare_to": "2017-03-18T04:34:15.606Z"
},
"lang": "painless",
"inline": "return ChronoUnit.DAYS.between(Instant.parse(params.compare_to), Instant.parse(params.search_timestamp))"
}
}
}
]
}
}
]
}
}
}
}
}
@peterdm safe to close?
Yup. Thanks.
I have a sample painless script which compares two static dates. If I run it inside
script_fields
I see the value I expect. However if I run it as ascript
query input to LTR, I get 1.Baffled!
Test Setup:
Query to Reproduce Error:
For me (5.3.0_0.1.0) the result comes out:
fields.days_between = [ 4 ]
_explaination.details[1].details[0].details[0].details[0].value = 1