Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Search by text score in mongodb

/**
 * query: The query in MQL.
 * First search the text using $match
 */
{
   $text:{$search:'Clara De'}
}


-------------

/**
 * specifications: The fields to
 *   include or exclude.
 *. Project results
 */
{
  _id:1,
  name:1,
'score':{$meta:'textScore'}
}

----------
/**
* query: The query in MQL.
* $match again
*/

{
     score:{ $gte: 0.2 }
}

Source by www.codegrepper.com #
 
PREVIOUS NEXT
Tagged: #Search #text #score #mongodb
ADD COMMENT
Topic
Name
5+3 =