How to disable the query cache


#1

Recently, I have noticed that searching by Elasticsearch had been performed a bit slowly. So I want to test the performance among the varied query circumstances.

Since Elasticsearch can cache the query result, I need to disable this function to reduce the unrelated affection between the two same query actions.

I set the false value to the setting parameters,
index.queries.cache.enabled
and
index.requests.cache.enable.

But actually it seems not working correctly. The second query action will obviously be faster than the first one during the two continuous query actions, which are in the same query clauses.

My query clause maybe looks like this:

{
    "from": 0, 
    "size": 20, 
    "query": {
        "bool": {
            "must": [
                {
                    "match": {
                        "content": "hello world"
                    }
                }, 
                {
                    "term": {
                        "state.raw": {
                            "value": "0"
                        }
                    }
                }, 
                {
                    "term": {
                        "news_type_id.raw": {
                            "value": "10000"
                        }
                    }
                }, 
                {
                    "range": {
                        "channel_id": {
                            "gte": "002000000000000000", 
                            "lt": "003000000000000000"
                        }
                    }
                }
            ]
        }
    }, 
    "sort": [
        {
            "mod_date": {
                "order": "desc", 
            }
        }
    ]
}

So my question is:

  • How can I disable the query cache, is there any other setting parameter controlling the cache behaviour?

  • What is the mechanism of the query or search cache? When I merely change one of the query parameters in the query clause shown above, for example, change the content matching condition from hello world to say hello, will Elasticsearch retrieve the search result from its cache? Is there any reference to understand the cache mechanism?

Thanks a lot.


(David Pilato) #2

The thing is that your OS also caches files that have been read recently. So the next reads are normally faster.

But may be you can ask the community to help about your slowness? Share your queries, responses...
May be use the profile API to understand which part is slow?


(system) #3

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