Hello
I am trying to improve search functionality in my app. It works fine in case of single expression scenario where user enters a single expression and the item that contains that expression. I want to change it so it can also work in the following scenario:
Item name in the database could be like this:
"Delicious dessert with banana and milk"
User' search input can be like this:
"banana milk"
So I want my search to return to the user all items that contain in their name field expressions "banana" and "milk".
I realize there may ways to achieve this (there is a text search functionality in mongodb for example), but I would appreciate your recommendation on what would be the simplest approach to solve this problem.
Right now my mapping looks like this:
and the JS mapping from search text field to where is as follows:
{
if (localStorage.ShowBlogArtOnly == 'on')
{
return '{$and: [{"Name":{"$regex":"' + value + '","$options":"im"}}, {"SourceID":"01"}]}';
}
else
{
return '{"Name":{"$regex":"' + value + '","$options":"im"}}';
}
}
else
{
return '{"id": {"$exists":false}}';
}