I need to run raw query with MongoDB. Now my $in
filter in pymongo looks like this:
{'category': {'$in': ['fruits', 'vegetables']}}
But it has revealed that sometimes category is Fruits
and filter does not match that value. I cannot fix all category
data in database because there is every day syncing and there are too many checks already. So, the only way is to improve the filter (it's not only category
in this filter, by the way).
So I wonder is there any way to ignore case with $in
operator?
To be totally clear, what I have now:
filter:
{'category': {'$in': ['fruits', 'vegetables']}}
data:
{'category': 'fruits'} // match
{'category': 'Fruits'} // does not match
What I need:
filter:
{'category': {'$ignorecase_in': ['fruits', 'vegetables']}}
data:
{'category': 'fruits'} // match
{'category': 'Fruits'} // match