今天有個同事說懷疑某個索引的一個字段是否有定義,因為查詢結果中一直沒有該字段。
我們可以使用exists來查詢那些在特定字段有值的文檔。
比如:
ec2-user@ip-172-31-31-122:~> curl -H "Content-Type: application/json" -XGET 'http://ip:9200/index_name/_search?pretty' -d '{"query":{"bool":{"must":[{"exists":{"field":"field_name.keyword"}}],"must_not":[],"should":[]}},"from":0,"size":10,"sort":[],"aggs":{}}'