So, I need to write something in Rails 3 that does a query to a MongoDB (If you don’t know mongo I don’t need the code just some ideas) that can query the data for close matches. For instance, let us say you are searching a collection for {item : a, item2 : b, item3 : c}. And exact match would have all three, but I also want matches that omit one of the three keys. I have two theories on how I should handle this. One would be to do multiple queries to omit certain parts of the data and the other would be to write a complex or statement. I don’t feel these are the best solutions though. Could anyone else suggest something to me? Even if it is from an SQL perspective, that would work for me.
I do need something that can be done fast. This is for a search that needs to return results as fast as possible.
Yet another approach would be to use MapReduce.
With it you can calculate how many fields a document matches.
Though it’s not very performant approach at the moment (but one of the most flexible).
The code can be something like this: