小编Ric*_*Mao的帖子

通过重复使用的术语查询过滤器加快 Elasticsearch 查询速度

我需要找出一个标签与另一组固定标签作为整体之间的共现时间。我有 10000 个不同的单个标签,固定标签集中有 10k 个标签。我以固定的时间范围循环访问一组固定标签上下文下的所有单个标签。我的索引内总共有 10 亿个文档,有 20 个分片。

这是elasticsearch查询,elasticsearch 6.6.0:

es.search(index=index, size=0, body={ 
        "query": {
          "bool": {
              "filter": [
                  {"range": {
                      "created_time": {
                       "gte": fixed_start_time,  
                       "lte": fixed_end_time, 
                       "format": "yyyy-MM-dd-HH"
                       }}},
                        {"term": {"tags": dynamic_single_tag}},
                        {"terms": {"tags": {
                            "index" : "fixed_set_tags_list",
                            "id" : 2,
                            "type" : "twitter",
                            "path" : "tag_list"
                        }}}
                       ]

                }
          }, "aggs": {
             "by_month": {
              "date_histogram": {
                  "field": "created_time",
                  "interval": "month",
                              "min_doc_count": 0,
                              "extended_bounds": {
                                  "min": two_month_start_time,
                                  "max": start_month_start_time}

              }}}
        }) 
Run Code Online (Sandbox Code Playgroud)

我的问题:是否有任何解决方案可以在elasticsearch内部有一个缓存,用于固定的10k组标签术语查询和时间范围过滤器,从而可以加快查询时间?对于我上面的查询,单个标签花费了 1.5 秒。

performance filter query-cache elasticsearch

1
推荐指数
1
解决办法
1922
查看次数

标签 统计

elasticsearch ×1

filter ×1

performance ×1

query-cache ×1