python - 弹性查询,其中字段在弹性中为空

标签 python elasticsearch

我正在尝试编写一个查询,它在 elastic 中搜索某个特定字段为 null。我们使用 Python Elasticsearch Client 在 python 中执行了这个查询。

查询:

{
    "_source": ["name"],
    "query": {
                "nested": {
                    "path": "experience",
                    "query": {
                        "match": {
                            "experience.resignation_date": {
                                "query": None
                            }
                        }
                    }
                }
            }
}

自从它的 python 我在查询部分使用了 None 但它抛出了这个错误。

elasticsearch.exceptions.RequestError: TransportError(400, 'parsing_exception', '[match] unknown token [VALUE_NULL] after [query]')

最佳答案

missing 查询已弃用,您正在寻找 bool/must_not + exists

{
  "_source": [
    "name"
  ],
  "query": {
    "nested": {
      "path": "experience",
      "query": {
        "bool": {
          "must_not": {
            "exists": {
              "field": "experience.resignation_date"
            }
          }
        }
      }
    }
  }
}

关于python - 弹性查询,其中字段在弹性中为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41742148/

相关文章:

elasticsearch - 使用ElasticSearch简单查询字符串进行范围查询

elasticsearch - 让elasticsearch只返回所有文档的id

python - 如何为自定义 pylint 检查器编写单元测试?

python - 属性错误 : 'module' object has no attribute 'get_altitude'

python - 在Python中通过乘以其他字典来创建字典

python - 合并 python 集合字典

java - 返回包含用户在 Elasticsearch 中输入的关键字的字符串列表

python - 如何使用 aggfunc 'min' 在dask中执行pivot_table?

elasticsearch - Elasticsearch 聚合始于

function - 根据doc字段的字符串值在Elasticsearch中 boost 结果