Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Does Elasticsearch accept 1 or 0 for searching on boolean field?

this is part of my elasticsearch query:

 {
    "match": {
        "value": {
            "query": "1",
        }
    }
}

value is a boolean field in my index, does elasticsearch accept 1 as true and 0 as false in search on the boolean field?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

as specified in the doc ES accept true/"true"/false/"false" as boolean values.

Other values like 0/1 will throw error in recent versions

error: failed to create query: Can’t parse boolean value 1, expected
[true] or [false]

NB: you should use a term query to filter in boolean field

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading