Querying a BinData field by $bitAllSet with an offset and size limit in MongoDB


Assume I have a BinData field of arbitrary length that stores n-byte items. The offset of each item is known before the query and all items are n bytes. I want to test an item at offset X with bitmask Y. It is important to mention that I don’t want to do a search, just a bitmask test, for the offset is known.

Currently, I’m reading the whole field and testing on my server side.

Is there a way to do it on MongoDB side?