# Filtering by Bit Array element

**URL:** <https://discuss.elastic.co/t/filtering-by-bit-array-element/58747>\
**Category:** Elasticsearch\
**Created:** [August 23, 2016, 9:26pm UTC](https://discuss.elastic.co/t/filtering-by-bit-array-element/58747 "2016-08-23T21:26:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![seperman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seperman/32/11550_2.png) [@seperman](https://discuss.elastic.co/u/seperman)\
**Post date:** [August 23, 2016, 9:26pm UTC](https://discuss.elastic.co/t/filtering-by-bit-array-element/58747/1 "2016-08-23T21:26:28Z")

</div>

Hello,

I have a bit array. And I want to filter based on if certain bits are ON or OFF. Looking at the Elasticsearch 2.3 docs, I don't see anything about bitarrays.

But it seems I can use an Array of Booleans or a Binary field.

Example: Let's say I have 2 documents each with a bit array field. Doc1 has 011100 and Doc2 has 00001 in that field. And I want to filter by 011000 which in this case only gives Doc1.

Any ideas how to do this in Elasticsearch?  
Sep

Edit: Another idea:

If I turn the bit array into many Bool fields, then it works. The doc might look ugly but it works. Basically if the bit array is 32 bit, then I will have 32 bool fields.

---

<div class="post-metadata">

**Author:** ![DiscussBuster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/discussbuster/32/11042_2.png) [@DiscussBuster](https://discuss.elastic.co/u/DiscussBuster)\
**Post date:** [August 24, 2016, 1:16am UTC](https://discuss.elastic.co/t/filtering-by-bit-array-element/58747/2 "2016-08-24T01:16:21Z")

</div>

Looks like you have it right, Elasticsearch doesn't have a bitarray field, and you need to break your field out.

---

<div class="post-metadata">

**Author:** ![seperman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seperman/32/11550_2.png) [@seperman](https://discuss.elastic.co/u/seperman)\
**Post date:** [August 24, 2016, 8:05pm UTC](https://discuss.elastic.co/t/filtering-by-bit-array-element/58747/3 "2016-08-24T20:05:18Z")

</div>

I posted it on Stackoverflow too. I think the recommended solution there is a good one.

> <https://stackoverflow.com/questions/39110962/bit-arrays-usage-and-filtering-in-elasticsearch>

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:25pm UTC](https://discuss.elastic.co/t/filtering-by-bit-array-element/58747/4 "2017-07-05T22:25:25Z")

</div>


