返回具有指定属性的所有文档,无论其值如何。

huangapple go评论53阅读模式
英文:

Return all documents in elastic that have a specified property regardless of value

问题

我正在尝试使用REST API查询Elasticsearch,以返回所有包含特定属性名称“content_blake3”的文档。属性的值不重要,我只想要具有这个属性的文档。

我尝试使用以下方式使用must和must_not请求,但仍然没有得到我需要的结果。

GET index-doc/_search
{
  "query": {
    "bool": {
      "must_not": {
        "match": {
          "content_blake3": ""
        }
      }
    }
  }
}

任何帮助都会很感激。

英文:

I'm trying to query elastic search using the REST API into returning me all documents that contain a specific property name of "content_blake3". the value of the property is irrelevant, I just want documents that have this property.

ive tried using the must and must_not requests like below but still not getting the result I need

GET index-doc/_search
{
  "query": {
    "bool": {
       "must_not": {
          "match":{
            "content_blake3": ""  
          }
        }
    }
  }
}

any help is always appreciated

答案1

得分: 1

你正在寻找存在查询:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html

GET index-doc/_search
{
  "query": {
    "bool": {
       "filter": {
          "exists":{
            "field": "content_blake3"
          }
        }
    }
  }
}
英文:

you're looking for the exists query: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html

GET index-doc/_search
{
  "query": {
    "bool": {
       "filter": {
          "exists":{
            "field": "content_blake3"
          }
        }
    }
  }
}

huangapple
  • 本文由 发表于 2023年3月3日 19:22:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/75626451.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定