I have the following kind of json in my database:
{
"_id" : "519817e508a16b447c00020e", "keyword" : "Just an example query",
"results" :
{
"1" : {"base_domain" : "example1.com", "href" : "http://www.example1.com/"},
"2" : { "base_domain" : "example2.com", "href" : "http://www.example2.com/"},
"3" : { "base_domain" : "example3.com", "href" : "http://www.example3.com/"},
"4" : { "base_domain" : "example4.com", "href" : "http://www.example4.com/"},
"5" : { "base_domain" : "example5.com", "href" : "http://www.example5.com/"},
"6" : { "base_domain" : "example6.com", "href" : "http://www.example6.com/"},
"7" : { "base_domain" : "example7.com", "href" : "http://www.example7.com/"},
"8" : { "base_domain" : "example8.com", "href" : "http://www.example8.com/"},
"9" : { "base_domain" : "example9.com", "href" : "http://www.example9.com/"},
"10" : { "base_domain" : "example10.com", "href" : "http://www.example10.com/"}
}
}
My goal is to have results for the following query:
> db.ranking.find({ $text: { $search: "http://www.example9.com"}})
It works when I create an index on all text fields
> db.ranking.ensureIndex({ "$**": "text" }))
But not when I create an index only over "results" field:
> db.ranking.ensureIndex( {"results" : "text"} )
Why?