mongodb text search with multiple fields

You should create a text index on the fields you want to search:

db.deals.ensureIndex({ name: "text", description : "text", category : "text" });

From the documentation of the $text operator:

$text performs a text search on the content of the fields indexed with a text index.

The index you created for your three fields is a compound index, not a text index. The text index will look like this:

{
    "v" : 1,
    "key" : {
        "_fts" : "text",
        "_ftsx" : 1
    },
    "name" : "name_text_description_text_category_text",
    "ns" : "test.deals",
    "weights" : {
        "category" : 1,
        "description" : 1,
        "name" : 1
    },
    "default_language" : "english",
    "language_override" : "language",
    "textIndexVersion" : 2
}

Tags:

Mongodb