Hi all, i just found a interesting issue.
i'm doing the elastic optimization stuffs
When run below code, average tooks 200~300 milliseconds
{
"from" : 0,
"size" : 10,
"query":
{
"function_score" : {
"query" : {
"bool" : {
"must" : [ {
"range" : {
"timestamp" : {
"from" : "1457403235000",
"to" : "1458008035000",
"include_lower" : true,
"include_upper" : true
}
}
}, {
"term" : {
"type" : "image"
}
}, {
"geo_bbox" : {
"geo" : {
"top_left" : [ -110.80651, 43.44131 ],
"bottom_right" : [ -110.804, 43.4403 ]
},
"type": "indexed"
}
} ]
}
},
"functions" : [ {
"script_score" : {
"script" : {
"file" : "hot_score",
"params" : {
"nowTime" : "1458008709945",
"gravity" : "2.0"
}
}
}
} ]
}
}
}
BUT ONCE change query to filter after function_score,it's only tooks 37~38 milliseconds
{
"from" : 0,
"size" : 10,
"query":
{
"function_score" : {
"filter" : {
"bool" : {
"must" : [ {
"range" : {
"timestamp" : {
"from" : "1457403235000",
"to" : "1458008035000",
"include_lower" : true,
"include_upper" : true
}
}
}, {
"term" : {
"type" : "image"
}
}, {
"geo_bbox" : {
"geo" : {
"top_left" : [ -110.80651, 43.44131 ],
"bottom_right" : [ -110.804, 43.4403 ]
},
"type": "indexed"
}
} ]
}
},
"functions" : [ {
"script_score" : {
"script" : {
"file" : "hot_score",
"params" : {
"nowTime" : "1458008709945",
"gravity" : "2.0"
}
}
}
} ]
}
}
}
So i think the filter is better than query.