I have a collection in DocumentDB 5.0 that has a text index on several fields.
Some of those fields allow for periods to be part of the field value.
I am not getting results when searching the text index using phrase matching (wrapped in escaped double quotes), which should be returning the record.
How can I match against these values in the text index?
The only way I can think of would be to have a secondary field with a sanitized or encoded value to match on.
Sample Data in Collection “persons”:
...
{
"_id" : ObjectId("5def456f4efb441e2375bd9d"),
"name": "some.bod3"
},
{
"_id" : ObjectId("5def456f4efb441e2375cd1e"),
"name": "nobod3"
}
...
Text Index Options
{
"v" : 1,
"name" : "Persons_TextIndex",
"ns" : "mydatabase.persons",
"weights" : {
"name" : 1.0
},
"textIndexVersion" : 1
}
Search Query for Document w/ Period (No Results):
No results are returned for documents with the period in the indexed field
db.getCollection("persons").find(
{
"$text" : {
"$search" : ""some.bod3""
}
}
);
Search Query for Document w/o Period (Result Found):
The expected result is found matching on the name field in the text index
db.getCollection("persons").find(
{
"$text" : {
"$search" : ""nobod3""
}
}
);
I tried using the phrase matching characters to wrap the search term:
""some.bod3""
I tried many permutations to see if escaping/removing/encoding the period through other ways would yield a match:
"some.bod3"
"some"."bod3"
'some"."bod3'
"somebod3"
"some%2Ebod3"
"some.*bod3"