Text search speeds in the cms

default discord avatar
3 months ago

More querying issues from me!

When doing a text search with a collection with a lot of entries it generates a query like the following:

Mongoose: posts.countDocuments({ '$and': [ { '$or': [ { text: { '$regex': /(?=.*(?:(?:[^\p{L}\p{N}])|^).*Sed.*(?=[^\p{L}\p{N}]|$)).+/i } } ] } ]}, {})
Mongoose: posts.find({ '$and': [ { '$or': [ { text: { '$regex': /(?=.*(?:(?:[^\p{L}\p{N}])|^).*Sed.*(?=[^\p{L}\p{N}]|$)).+/i } } ] } ]}, { limit: 10, sort: { createdAt: -1 }, skip: 0, projection: {} })

This regex seems to take a while to process with a large amount of data (reprod example



Will it ever be possible to customise how this text search works?

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.