问题
My wish is to search docs where field_a exists, and fields_b doesn't exist. Is there a way to do this using the Lucene query syntax in Kibana (Search field in the Discover section of Kibana).
I've tried using _missing_:field_b without success (_exists_ works).
I've found this but it doesn't help much:
GET /_search
{
"query": {
"bool": {
"must_not": {
"exists": {
"field": "user"
}
}
}
}
}
回答1:
For lucene search syntax:
_exists_:field_a AND !_exists_:field_b
For elasticsearch search syntax:
{
"query" : {
"bool" : {
"must" : [
{"exists" : { "field" : "field_a" }}
],
"must_not": [
{"exists" : { "field" : "field_b" }}
]
}
}
}
来源:https://stackoverflow.com/questions/50996197/elasticsearch-6-2-kibana-query-one-field-must-exists-and-one-field-must-not-e