(Quick Reference)

Purpose

Executes a MongoDB $text search query

Examples

assert Product.searchTop("coffee").size() == 5
assert Product.searchTop("coffee", 3)

Description

The searchTop method uses MongoDB’s full text search support to perform full text search on a "text" index with the results sorted by the MongoDB score. The method by default returns the top 5 results, but the second argument can be used to customize the number of results (top 3, top 10 etc.)