Best way to check if a field exist in an Elasticsearch document

前端 未结 5 2180
梦如初夏
梦如初夏 2020-12-14 15:21

May be is a very stupid question, What is the best way to check if a field of a document in elasticsearch exists? I can\'t find anything in the documentation.

For ex

5条回答
  •  旧巷少年郎
    2020-12-14 15:54

    You can use exists filter:

    {
      "query": {
        "filtered": {
          "filter": {
            "exists": {
              "field": "status"
            }
          },
          "query": {
            "match_all": {}
          }
        }
      }
    }
    

    Regards, Alain

提交回复
热议问题