Elasticsearch没有为[exists]注册的查询

san*_*eep 3 elasticsearch

运行以下查询后,我收到异常,因为没有为[exists]注册查询.请帮我.

{
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "must": {
            "match": {
              "_all": {
                "query": "cardio new york"
              }
            }
          }
        }
      },
      "functions": [
        {
          "gauss": {
            "geo_location": {
              "origin": {
                "lat": 40.7127,
                "lon": -74.0059
              },
              "scale": "100km",
              "offset": "0km",
              "decay": 0.9
            }
          }
        },
        {
          "gauss": {
            "startdate": {
              "origin": "now",
              "scale": "30d",
              "offset": "30d"
            }
          },
          "weight": 0.5
        }
      ],
      "filter": {
        "query": {
          "bool": {
            "must": {
              "match": {
                "_all": {
                  "query": "cardio new york"
                }
              }
            },
            "should": {
              "exists": {
                "fields": [
                  "venue",
                  "geo_location"
                ]
              }
            }
          }
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我试图在结合bool匹配查询的function_score之后过滤搜索结果.

imo*_*tov 6

exists不是查询,它的过滤器你不能在bool查询中使用它,而是我会使用bool过滤器和仅包装match到这样的query过滤器:

 "filter": {
    "bool": {
      "must": [{
        "query": {
          "match": {
            "_all": {
              "query": "cardio new york"
            }
          }
        }
      }, {
        "exists": {
          "fields": [
            "venue",
            "geo_location"
          ]
        }
      }]
    }
  }
Run Code Online (Sandbox Code Playgroud)