Hi everyone,
I would be very appreciated if somebody could help me with my question below.
-
db.getCollection(SomeCollection’).find({
“field1”:25, //int32, indexed (separate index)
“field2”:“Option1”, // string, indexed (separate index)
“field3”:/\Qtest@example.com\E/, //string, indexed (separate index)
“field4”:/\QSome phrase\E/, // very big string, NOT indexed, searching for phrase with regex
“field5”: {$gt: new ISODate(“2021-01-01T00:00:00Z”)} // datetime, indexed
}) -
db.getCollection(SomeCollection’).find({
“field1”:25, //int32, indexed (separate index)
“field2”:“Option1”, // string, indexed (separate index)
“field3”:/\Qtest@example.com\E/, //string, indexed (separate index)
$text: {$search: ““Some phrase””}, // full text search index created for this field, searching for phrase
“field5”: {$gt: new ISODate(“2021-01-01T00:00:00Z”)} // datetime, indexed
})
MongoDB version 4.2 is used.
As I see from winning plan (actually it is always one), in second query indexes are not used (well, except text index), so I’m receiving the results with second query even slower than with first one without any index at all. This problem is getting high priority for our customers, is it possible somehow increase the speed of such search and make it using the indexes? I mean full-text search + additional filters or make any of this two queries somehow max speed. The number of additional filters could be different, I put that 5 fields just as an example.
I’m thinking about sharding, but that’s not an option at the moment.
thank you in advance!