Text search speeds in the cms

default discord avatar
devperson
3 months ago
4

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

https://github.com/payloadcms/payload/compare/master...rymate1234:payload:bug/filtering

)



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!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

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