Back to main page

PlainSimilarity

Concept:

$similarity without arguments is similar to $similarity operation with arguments. The difference is that $similarity will base the similarity on the where clause contents.

Consider the following example. It will return all the products, that contain 'iphone' in the title. It also sorts the results by their similarity to the 'iphone' and highlight the 'iphone' term in the product title field.

{
   "from": "product",
   "where": { "title" : { "$match" : "iphone" } },
   "get" : "message",
   "orderBy": "$similarity",
   "select" : ["title", "$highlight"]
}

Format:

    $similarity