英文:
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"
          }
        }
    }
  }
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论