-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$in
operator to search tagged documents
#42
Comments
Test case for future implementation db.tags.insert({"tags":["red", "tall", "cheap"]});
db.tags.insert({"tags":["blue", "tall", "expensive"]});
db.tags.insert({"tags":["blue", "little", "cheap"]});
# find all blue
db.tags.find({tags: "blue"})
# find all blue and cheap
db.tags.find({ tags: { $all: ["cheap", "blue"] } } )
# find all not blue
db.tags.find({tags: { $ne: "blue" } })
# find all "blue" and "cheap" but not "red" and not "tall"
db.tags.find({ $and: [ {tags: { $all: ["blue", "cheap"] } }, { tags: { $nin: ["red", "tall"] } } ] }) |
I did a workaround saving a string version of my tags as and querying with col.find({'tags_string': {'$regex': '.*,python,.*'}}) |
@schapman1974 @jjonesAtMoog can you guys add hacktoberfest label to this issue please? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a document like this
It has a
'tags': ['python', 'flask', 'pythonplanet', 'pyplanet', 'new']
and I have more documents with tagpython
When I search using
{'tags': 'python'}
Ok that is expected so lets use
{'$in': 'python'}
or with a list:
{'$in': ['python', 'flask']}
I checked the source code and currently the
$in
operator only works in thereverse
way, it works currently to match a single field against an array of possibilities. But not to check an array against a single value or array.The text was updated successfully, but these errors were encountered: