I am new to Elasticsearch. I have a mapping which has a boolean field.
I need to filter on this field, and I am not sure which filter to use. Based on my research, I probably should use term filter. Is this correct? To me, the term filter seems to be designed for string fields.
Thanks!
Boolean, or a bool query in Elasticsearch, is a type of search that allows you to combine conditions using Boolean conditions. Elasticsearch will search the document in the specified index and return all the records matching the combination of Boolean clauses.
Boolean queries in Elasticsearch are a popular query type because of their versatility and ease of use. Boolean queries, or bool queries, find or match documents by using boolean clauses. For the vast majority of cases, the filtering clause will be used because it can be cached for faster search times.
Boolean queryedit. A query that matches documents matching boolean combinations of other queries. The bool query maps to Lucene BooleanQuery . It is built using one or more boolean clauses, each clause with a typed occurrence.
must means: Clauses that must match for the document to be included. should means: If these clauses match, they increase the _score ; otherwise, they have no effect. They are simply used to refine the relevance score for each document.
Yes, a term filter is the correct choice: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-term-filter.html
Think of the boolean field as containing either the term T or the term F, so a term filter is appropriate.
See these two discussions: http://elasticsearch-users.115913.n3.nabble.com/Which-filter-could-be-used-on-boolean-field-td4035426.html and http://elasticsearch-users.115913.n3.nabble.com/Simple-equality-filter-td3063743.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With