'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.
Solution 1:[1]
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.
{
$or: [
{"field_1": {"$regex": YOUR_SEARCH_STRING} },
{"field_2": {"$regex": YOUR_SEARCH_STRING} }
]
}
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.
Solution 2:[2]
You can use $regex for partial text search functionality. Which is what I believe you are looking for.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tyler2P |
| Solution 2 | Dylan L. |
