【问题标题】:Check if elasticsearch query results are coming from cache or not?检查elasticsearch查询结果是否来自缓存?
【发布时间】:2019-09-30 17:04:06
【问题描述】:

我需要比较弹性搜索索引的 2 个不同的索引(相同的数据,不同的分片数),为此我使用了一些慢速搜索查询并访问这些索引,但我怀疑是一个索引正在获取实时流量,因此我的查询结果可能来自缓存。

有什么方法可以判断,结果是来自缓存还是我们可以指定不从缓存中获取结果的任何参数?

【问题讨论】:

    标签: elasticsearch caching


    【解决方案1】:

    默认情况下,请求缓存只会缓存搜索结果 size=0 的请求,所以它不会缓存hits,但它会 缓存hits.totalaggregationssuggestions

    request_cache 查询字符串参数可用于根据每个请求启用或禁用缓存。如果设置,它将覆盖索引级别设置:

    GET /my_index/_search?request_cache=true
    {
      "size": 0,
      "aggs": {
        "popular_colors": {
          "terms": {
            "field": "colors"
          }
        }
      }
    }
    

    查看更多: https://www.elastic.co/guide/en/elasticsearch/reference/current/shard-request-cache.html#_enabling_and_disabling_caching_per_request

    【讨论】:

    • 但这只会禁用分片级别的请求缓存,不会禁用节点级别的查询缓存
    猜你喜欢
    • 1970-01-01
    • 2017-08-17
    • 1970-01-01
    • 2021-05-02
    • 1970-01-01
    • 2011-05-06
    • 2014-01-18
    • 2010-11-14
    • 1970-01-01
    相关资源
    最近更新 更多