Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Text search speeds in the cms

default discord avatar
devperson2 years ago
2

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?

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.