I need to find the items from MongoDb db using Mongoid gem in rack application. Here is what I have:
items = items.any_of(
{item_id: q}, #ok
{title: /q/},
{title2: /q/},
{code: q}, #ok
{seller: q} #ok
)
I need to improve search by title
and title2
.
First off, how to make it not case sensitive?
Secondly, if q
contains many words, I want it to search by any word it contains.
How can I do that?