Hi, all. I found some unexpected behaviour with script query (script is executing twice in a simple query). The steps to reproduce the issue:
My elastic search version: 2.4.6
My elasticsearch.yml:
script.indexed: true
Steps:
- I have one simple document, doc1.json:
{
"id": "1",
"tags": "t1"
}
- Insert doc1 in Elastic:
http PUT localhost:9200/default/type1/1 @doc1.json
- I have one simple groovy script, script1.json (just returns the score and print it):
{
"script": "println('Score is ' + _score * 1.0 + ' for document ' + doc['id'] + ' at ' + DateTime.now().getMillis()); return _score;"
}
- Register script1:
http POST 'localhost:9200/_scripts/groovy/script1' @script1.json
- Execute this query_with_script.json:
{
"query":{
"function_score":{
"query":{
"bool":{
"must":{
"match":{
"tags":{
"query":"t1",
"type":"boolean"
}
}
}
}
},
"functions":[
{
"script_score":{
"script":{
"id":"script1",
"lang":"groovy"
}
}
}
],
"boost_mode":"replace"
}
},
"explain" : true
}
http GET 'localhost:9200/default/type1/_search' @query_with_script.json
- Why in Elastic search logs I see that the script is executed in two different times?
Score is 0.19178301095962524 for document [1] at 1516586818596
Score is 0.19178301095962524 for document [1] at 1516586818606
Thanks a lot!