Cache - Weird behavior in function_score

Hello guys,

Currently, at my work, I was testing elastic search queries - in terms of performance - through millions of documents.

During the tests, I found a weird behavior of caching feature.

We use - and need to use - has_child into our queries to perform sorting based on many child's values.

We've built two queries, basically:

1 -
POST type_/search
{
...
"has_child":
"query": {
"function_score": {
"query": {
"bool": {
"filter": {
....
},
}
},
"functions": [...],
"score_mode": "first"
}
}
}

2 -
POST type_/search
{
...
"has_child":
"query": {
"function_score": {
"filter": {
....
},
"functions": [...],
"score_mode": "first"
}
}
}

So far as I know, the caching feature should work with the same behaviour for both queries (as I'm using filter expression to filter the data, instead of any other expression), but results doesn't say the same, check this benchmark:

Query 1
The first search: took around 2000-2500 ms
Other searches (with cache): took around 800-1100 ms

Query 2
The first search: took around 1800-2200 ms
Other searches (with cache): took around 300-400 ms (PERFECT!)

I used this article to reach this scenario:
https://www.elastic.co/guide/en/elasticsearch/guide/current/function-score-filters.html

Is there something bad with caching or Is there any other concept that I missed during my way?

Best regards,

Vinicius Defeo

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.