Details
Description
We've decided to implement a few bittest query operators:
$bitsAllSet  matches if the input bit positions are all 1
$bitsAllClear  matches if the input bit positions are all 0
$bitsAnySet  matches if any of the bit positions are 1
$bitsAnyClear  matches if any of the bit positions are 0
These operators can take an array of bit positions, a 64bit number bitmask, or a BinData bitmask. For the number and BinData bitmasks, the bit positions to check are the positions of 1's in their binary representation.
The operators will only match against int32, int64, doubles, and binary data. Other types will not match.
Note that bit position 0 means the least significant bit.
An example using the array of bit positions syntax:
db.foo.insert( { a: 43 } ); // Binary form: 101011 (leading zeroes truncated)

db.foo.find( { a: { $bitsAllSet: [0, 1, 3] } }, { _id: 0, a: 1 } );

Result: { a: 43 }

An example using the bitmask syntax:
db.foo.insert( { a: 43 } ); // Binary form: 101011 (leading zeroes truncated)

db.foo.find( { a: { $bitsAllSet: 9 } }, { _id: 0, a: 1 } ); // Binary form of the bitmask: 1001

Result: { a: 43 }

Issue Links
 is duplicated by

SERVER8657 Add bitfied operators to query and update
 Closed
 is related to

SERVER3281 Support $bit operator for binary types
 Open
 links to
I second on this. Having bitwise queries enables some very memoryefficient structures like packed integers. It can be huge saving of index size.