I'm currently trying to query ES through Python, using elasticsearch-py but with no success... I'm testing the request on the "elasticsearch-head" plugin and it works fine (results come scored)
However, when I do it in Python something seems to be wrong and although I get the same results, they are not scored properly...
here is the code:
custom_query={
"query": {
"function_score": {
"query": {
"match_all": {}
},
"functions": [
{
"script_score": {
"lang": "groovy",
"script": "_score+20",
"params":{"myMap":{}}
}
}
]
}
}
}
This is my custom query, very simple, just to test the scoring mechanism.
src = es.search(index=['test'],scroll='60s',search_type='scan',size=10,body=custom_query)
now I test it out:
while(1):
src = es.scroll(scroll_id=sid, scroll='60s')
sid = src['_scroll_id']
kws.extend(src['hits']['hits'])
All this gives is a set of results that have been improperly scored... I've even enabled "_explanation" to understand if the script is being utilized... This meaning: - "_score" is always 0 - "_explanation" shows something like:
{
'description': 'function score',
product of:'',
'value': 21.0,
'details': [
{
'description': 'ConstantScore(*:*)',
product of:'',
'value': 1.0,
'details': [
{'description': 'boost', 'value': 1.0}, {'description': 'queryNorm', 'value': 1.0}
]
},
{
'description': 'Math.min of',
'value': 21.0,
'details': [
{
'description': 'script score function',
computed with script:"return _score+30;" and parameters: \n{myMap={}}', 'value': 21.0
},
{
'description': 'maxBoost',
'value': 3.4028235e+38
}
]
},
{
'description': 'queryBoost',
'value': 1.0
}
]
}