匹配无效的弹性搜索日期范围

Elastic search date range with match not working

我正在尝试获取与以下 2 个日期之间的特定字段匹配的记录

{
  "query": {
    "bool": {
         "must": [
            {
              "range": {
                "createdtime": {
                  "gte": "now-1y",
                  "lte": "now",
                  "boost" : 2.0
                }
              }
            },
            {
               "match": {
                  "id": 350403
               }
            }
         ]
    }
  }
    "size" : 10000,
    "from": 0,
    "sort": { "createdtime" : {"order" : "desc"} }  

但是它抛出异常,谁能帮忙修复一下?

您应该正确地格式化和缩进您的查询,这样更容易发现错误。正确的查询可以在下面找到:

{
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "createdtime": {
              "gte": "now-1y",
              "lte": "now",
              "boost": 2
            }
          }
        },
        {
          "match": {
            "id": 350403
          }
        }
      ]
    }
  },
  "size": 10000,
  "from": 0,
  "sort": {
    "createdtime": {
      "order": "desc"
    }
  }
}