-
Type:
Question
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 3.2.7
-
Component/s: Index Maintenance
-
None
-
None
-
0
-
None
-
None
-
None
-
None
-
None
-
None
What indexing strategy could be the best for this type of searchs:
db.getCollection('collection').find(
{'name': /a/i})
(Find command will always try to find a specific substring from a string, without another regex options).
We know that if there is a normal index over the "name" field, this is used, by we need more performance.
Could it be to change this find command to a "text" search command over another atribute calculated based upon all the posible letters combinations?, by example, if we had in attribute:
"name" the value "antonio"
whe could generate another atribute:
"name_extended" with values "a an ant anto anton antoni antonio"
and generate a text index over it:
db.collection.createIndex(
{ "name_extended": "text"})
and change our original find command to:
db.getCollection('collection').find({$text: {$search: "a", $caseSensitive: false}} )
Could it be to make a good sharding policy to spread the scan phase along multiple servers?
Could it be to focus in our application to make some limitations (only search for begining words, case sensitive)?
We´ll need your feedback to go in one or another direction, or another ideas/techniques that we haven´t take into account.