I have to add partial text Search functionality. Can anyone suggest me how to add partial text search functionality in mongodb using nodejs.
I have to add partial text Search functionality. Can anyone suggest me how to add partial text search functionality in mongodb using nodejs.
2
Answers
You can use
$regex
for partial text search functionality. Which is what I believe you are looking for.MongoDB $regex Docs
Just to clarify, you’re looking for a partial text match in multiple columns?
If I’m understanding you I believe you could use
$or
with a$regex
for each field in which you’re interested in matching.You can use a text match with forward slash. For example if the search term is "mongodb" you could say
"$regex": /mongodb/
and it would search a field for that phrase.I’m new to Stack Overflow so if this isn’t what you’re looking for let me know and I can try to answer more specifically.