Skip to content

Creating Full Text Search with Index in MongoDB #2127

Answered by B4nan
Urento asked this question in Q&A
Discussion options

You must be logged in to vote

Not sure what you are up to, you don't query the index, you query properties of the entity, the index just helps to make the query faster. You are probably looking for $text operator.

Never really used mongo full text search myself, but something like this might be what you want (note you don't reference the index name at all):

const customers = await DI.customerRepository.find({ [expr('$text')]: { $search: query } });

Note you need to use the expr helper function to escape strict typings.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Urento
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2126 on August 15, 2021 10:31.