I have a query criteria which looks for an array of elements ( tags_array ) to match :
User.all_in('watchlists.tags_array' => tags_array)
I’d like the criteria to be CASE-INSENSITIVE, meaning I want it match %w[Ruby Web Framework] as well as %w[RUBY WEB FRAMEWORK] or %w[ruby web framework] and so on …
Is this possible via mongoid or do I have to use external filter tricks ?
Thanks to the support of Jordan and just for tracking purposes (for myself and others as well), I’ll post the entire solution.
Yes, Yuriy Goldshtrakh was right, MongoDB still does not support case-insensitive query but MongoID has regex, my only doubt is regarding performance degradation as already said by “mu is too short” but I didn’t check until now … anyway here it is :
No normalization at save/create mongoid level, the tags are saved either upper or lower case.
Normalization (case-insensitive matching of tags) are realized entirely during the nested quering criteria ( it’s nested because of embedded one to many model ).
If you have better idea or code, please have a post.
I’d also thanks Luiz K. for answering, even if I’ll not follow that way: normalization at data level is too restrictive in my view, loosing semantic and elasticity “user” side (who actually is tagging). Anyway could be a good solution for other requirements.
Many thanks
Luca G. Soave