Elasticsearch error: [exists] unknown token [START_ARRAY] after [field]

Elasticsearch error: [exists] unknown token [START_ARRAY] after [field]

我正在尝试使我的 elasticsearcherh 查询正常工作,但出现此错误:

org.elasticsearch.common.ParsingException: [exists] unknown token [START_ARRAY] after [field]

查询应该获取两年 (1500,1550) 之间 date.old 或 date.new 日期的所有文档,并且还包括这些字段具有未定义值的文档.

这是我的查询:

{
   "query":{
      "bool":{
         "should":[
            {
               "range":{
                  "date.old":{
                     "gte":1500,
                     "lte":1550
                  }
               }
            },
            {
               "range":{
                  "date.new":{
                     "gte":1500,
                     "lte":1550
                  }
               }
            },
            {
               "bool":{
                  "must_not":{
                     "exists":{
                        "field":"date.new"
                     }
                  }
               }
            },
            {
               "bool":{
                  "must_not":{
                     "exists":{
                        "field":"date.old"
                     }
                  }
               }
            }
         ]
      }
   }
}

有人看到这里的问题吗?谢谢!

点击上述问题中给出的相同搜索查询不会出现解析错误。

添加带有索引映射、索引数据和搜索结果的工作示例

索引映射:

{
  "mappings": {
    "properties": {
      "date": {
        "properties": {
          "old": {
            "type": "long"
          },
          "new": {
            "type": "long"
          }
        }
      }
    }
  }
}

索引数据:

{
  "data": {
    "new": 1501,
    "old": 10
  }
}

{
  "title": "elasticsearch"
}

搜索结果:

"hits": [
  {
    "_index": "65112793",
    "_type": "_doc",
    "_id": "1",
    "_score": 1.0,
    "_source": {
      "date": {
        "new": 1501,
        "old": 10
      }
    }
  },
  {
    "_index": "65112793",
    "_type": "_doc",
    "_id": "2",
    "_score": 0.0,
    "_source": {
      "title": "elasticsearch"
    }
  }
]

编辑 1:

基于以下评论:

搜索查询:

{
  "query": {
    "bool": {
      "should": [
        {
          "range": {
            "date.old": {
              "gte": 1500,
              "lte": 1550
            }
          }
        },
        {
          "range": {
            "date.new": {
              "gte": 1500,
              "lte": 1550
            }
          }
        }
      ],
      "must": [
        {
          "bool": {
            "must_not": {
              "exists": {
                "field": "date.new"
              }
            }
          }
        },
        {
          "bool": {
            "must_not": {
              "exists": {
                "field": "date.old"
              }
            }
          }
        }
      ]
    }
  }
}