title: Storing and indexing binary strings in a database
body: <p>A binary string as defined here is fixed size "array" of bits. I call them strings since there is no order on them (sorting/indexing them as numbers has no meaning), each bit is independent of the others. Each such string is N bits long, with N in the hundreds.</p>
  
  <p>I need to store these strings and given a new binary string query for the nearest neighbor using the Hamming distance as the distance metric.<br>
  There are specialized data-structures (metric-trees) for metric-based search (VP-trees, cover-trees, M-trees), but I need to use a regular database (MongoDB in my case).</p>
  
  <p>Is there some indexing function that can be applied to the binary strings that can help the DB access only a subset of the records before performing the one-to-one Hamming distance match?
  Alternatively, how would it be possible to implement such Hamming based search on a standard DB?</p>