I have a document that has the following Schema
{
description : String,
tags : [String]
}
I have indexed both fields as text, but the problem is that whenever I search for a specific string within the array, it will return the document only if the string is the first element of the array. Therefore it seems that the $text index only works for the first element, is this how mongo inherently works or is there an option that must be passed to the index?
Example document
{
description : 'random description',
tags : ["hello", "there"]
}
The object that created the index
{description : 'text', tags : 'text'}
The query
db.myCollection.find({$text : {$search : 'hello'}});
returns a document but
db.myCollection.find({$text : {$search : 'there'}});
does not return anything.
using version 2.6.11
I have other indexes but these are the only text indexes. Here is the corresponding output of db.myCollection.getIndexes()
{
"v" : 1,
"key" : {
"_fts" : "text",
"_ftsx" : 1
},
"name" : "description_text_tags_text",
"ns" : "myDB.myCollection",
"weights" : {
"description" : 1,
"tags" : 1
},
"default_language" : "english",
"language_override" : "language",
"textIndexVersion" : 2
},