Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Allowing non-existence on a filtered term in ElasticSearch with tire

I have a boolean field that I'm trying to filter by, but I want to fetch documents that either have a specific value for this field, or doesn't have this field populated at all. How can I accomplish this?

like image 517
Randuin Avatar asked Dec 30 '25 17:12

Randuin


1 Answers

There are two ways of dealing with it. First of all, you can use null_value attribute in the mapping to specify how null value should be indexed. Alternatively, you can use exists or missing filters along with bool or or filters to augment your query.

like image 109
imotov Avatar answered Jan 01 '26 09:01

imotov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!