Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElasticSearch/Lucene query string — select "field X exists"

How do I query ElasticSearch through Kibana to select items that have field X?

For example, I have a mapping with fields {"a": {"type": "string"}, "b": {"type": "string"}}, and two documents

{"a": "lalala"}
{"a": "enoheo", "b": "nthtnhnt"}

I want to find the second document without knowing what its b actually is.

like image 825
Mischa Arefiev Avatar asked May 13 '15 13:05

Mischa Arefiev


1 Answers

It's been a while since these answers were given. In case anyone needs a more updated answer, the docs now give this example for selecting results that have a certain field.

In query-string syntax:

where the field title has any non-null value:

_exists_:title

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_field_names

like image 67
James Avatar answered Sep 30 '22 19:09

James