How to find similarity in document field MongoDB?
<p>Given data that looks like this:  </p>

<pre><code>{'_id': 'foobar1',
 'about': 'similarity in comparison',
 'categories': ['one', 'two', 'three']}
{'_id': 'foobar2',
 'about': 'perfect similarity in comparison',
 'categories': ['one']}
{'_id': 'foobar3',
 'about': 'partial similarity',
 'categories': ['one', 'two']}
{'_id': 'foobar4',
 'about': 'none',
 'categories': ['one', 'two']}
</code></pre>

<p>I would like to find a way to get a similarity between a single item and all other items in the collection then return them in order of highest similarity. Similarity is based on number of words in common, there is already a function <code>int similar(String one, String two)</code></p>

<p>For example: if I want the similarity list for <code>about</code> field of <code>foobar1</code>, it would return </p>

<p><code>[{'_id': 'foobar2'}, {'_id': 'foobar3'}, {'_id': 'foobar4'}]</code></p>

<p>I am doing this with morphia, but with just the mongoDB implementation, I could figure the rest out</p>