简体   繁体   English

如何将此Elasticsearch查询从2.x转换为5.x索引?

[英]How to convert this elasticsearch query from 2.x to 5.x index?

Our system upgraded elasticsearch from 2.x to 5.x. 我们的系统将elasticsearch从2.x升级到了5.x。 Now query's are not working in 5.x written in 2.x. 现在查询无法在以2.x编写的5.x中工作。 So I have to convert elasticsearch query from 2.x to 5.x index? 所以我必须将Elasticsearch查询从2.x转换为5.x索引吗?

Please suggest how to convert this query to elasticsearch 5.x query? 请建议如何将该查询转换为elasticsearch 5.x查询? _score field will not be affected and able to cache this query. _score字段将不受影响,并且可以缓存此查询。

{
  "size": 12,
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "pageType": "ulp_comb"
              }
            },
            {
              "range": {
                "date": {
                  "gte": "2017-09"
                }
              }
            }
          ],
          "must_not": [
            {
              "term": {
                "entityId": 0
              }
            }
          ]
        }
      }
    }
  }
}

You just need to change filtered to bool 您只需要更改filteredbool

{
  "size": 12,
  "query": {
    "bool": { // change to bool
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "pageType": "ulp_comb"
              }
            },
            {
              "range": {
                "date": {
                  "gte": "2017-09"
                }
              }
            }
          ],
          "must_not": [
            {
              "term": {
                "entityId": 0
              }
            }
          ]
        }
      }
    }
  }
}

Hope it helps 希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM