Here is a challenge to my fellows MongoDB and NodeJs Devs
I have a search form, in which a user can enter the following:
225/65R16 71T K715 Hankook
As for my mongodb, I have a collection with the following docs:
1- { _id: SomeId, Description: 225/65R16 71T K715, Brand: Hankook, Ref: 123455 }
2- { _id: SomeId, Description: 225/65R16 71T K715, Brand: Continental, Ref: 123456 }
3- { _id: SomeId, Description: 225/65R16 94T Energy, Brand: Hankook, Ref: 123457 }
How can I do that so that when searching any combination below I get results for the docs 1 and 3 above?
List of combinations:
Hankook
225/65R16
225/65R16 Hankook
225 Hankook
225 Han
71Tis in document #2. Also, there's no way that would match on document #3. However, if you're looking to do a search in the manor it appears you are, you should look into text search indexes. Here's a good article: code.tutsplus.com/tutorials/…$oroperator: docs.mongodb.com/v3.2/reference/operator/query/or