Elasticsearch 7.14 constant_score 有两个过滤器?

Elasticsearch 7.14 constant_score with two filters?

我在使用两个过滤器在 ES 7.14 中创建 constant_score 查询时遇到问题。我的查询是:

"query": {
            "constant_score": {
                "filters": [
                    {"exists": {"field": "_geopoint"}},
                    {"term": {"project_id": "123"}},
                ]
            }
        },

基本上,我需要文档在 _geopoint 中对 project_id = '123' 有任何值的分数。但我得到错误:

unexpected token [START_ARRAY]

我的映射是:

"mappings": {
            "properties": {
                "project_id": {"type": "keyword"},
                "form_id": {"type": "keyword"},
                "submission_id": {"type": "keyword"},
                "_submitted_date": {"type": "date"},
                "_xform_id_string": {"type": "keyword"},
                "_submitted_by": {"type": "keyword"},
                "_user_id": {"type": "keyword"},
                "_project_code": {"type": "keyword"},
                "_geopoint": {"type": "text"},
                "_geolocation": {"type": "geo_point"},
            }
        },

我也试过和:

"filter": {
           "and": {
               "filters": [
                  {"exists": {
                     "field": "_geopoint"
                  }},
                  {"term": {
                     "project_id": "123"
                  }}
               ]
           }
       }

但是我对“和”有疑问

如有任何想法,我们将不胜感激。 constant_score官方文档只有一个过滤器

试试这个:

{
  "query": {
    "constant_score": {
      "filter": {
        "bool": {
          "filter": [
            {"exists": {"field": "_geopoint"}},
            {"term": {"project_id": "123"}},
          ]
        }
      }
    }
  }
}