Title: How to use filter_docs with multiple filter from the same key (bug?) · docarray/docarray · Discussion #1749 · GitHub
Open Graph Title: How to use filter_docs with multiple filter from the same key (bug?) · docarray/docarray · Discussion #1749
X Title: How to use filter_docs with multiple filter from the same key (bug?) · docarray/docarray · Discussion #1749
Description: How to use filter_docs with multiple filter from the same key (bug?)
Open Graph Description: Hey there! Thanks for the great work! I am currently struggling a bit with the filter_docs: I have a docsList of a doc like this: class ImageDoc(BaseDoc): url: ImageUrl test_index: Optional[int] lo...
X Description: Hey there! Thanks for the great work! I am currently struggling a bit with the filter_docs: I have a docsList of a doc like this: class ImageDoc(BaseDoc): url: ImageUrl test_index: Optional[int] lo...
Opengraph URL: https://github.com/docarray/docarray/discussions/1749
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"How to use filter_docs with multiple filter from the same key (bug?)","text":"Hey there!
\nThanks for the great work!
\nI am currently struggling a bit with the filter_docs:
\nI have a docsList of a doc like this:
\nclass ImageDoc(BaseDoc):\n url: ImageUrl\n test_index: Optional[int]\n local_path: Optional[str]\n tensor: Optional[ImageTorchTensor]\n embedding: Optional[AnyEmbedding]
\nNow I want to filter out all the docs which have either test_index 3 or 9 . What would be the query for this? This does not work:
\nquery = {\n '$and': {\n 'test_index' : {'$neq' : 3},\n 'test_index' : {'$neq' : 9}\n }\n}\n
\nAnd only filters out only the 9 (second part of the query). This seems to be always happening when using two times the same index in the query.
\nWhat would be the correct approach for this?
\nCurrently I am solving this with a regex expression, but that does not seem right haha
\nThanks!
","upvoteCount":1,"answerCount":3,"acceptedAnswer":{"@type":"Answer","text":"Hello @simonschoenhofen .
\nI finally got time to look at this issue.
\nThis does not seem to be a bug, since the query is a dictionary, a dictionary cannot contain 2 entries of the same key and this is why docarray only sees one of the entries.
\nI would say that the query should be designed differently using the nin (not in a set) clause:
\nquery = {
\n'test_index' : {'$nin' : [3, 9]},
\n}
","upvoteCount":2,"url":"https://github.com/docarray/docarray/discussions/1749#discussioncomment-6798945"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:996e40c4-5d43-e43f-a5d7-59a79bcf03ef |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | A484:2A271A:2ACA1CF:37D686C:69648EF3 |
| html-safe-nonce | 1c13ef5d9c9842ba05cb18e3039e7dc11149912fd35f8e13f609b970487b672e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDg0OjJBMjcxQToyQUNBMUNGOjM3RDY4NkM6Njk2NDhFRjMiLCJ2aXNpdG9yX2lkIjoiNTA0MjEwNzExMTM5MDk0MjU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c67c1a420b8a5262e59735bdf934179179310f68f622bac9f80a61652cb4ac9e |
| hovercard-subject-tag | discussion:5509231 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/docarray/docarray/1749/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/166d24cf124d8e8e30b6fb92f162872f3320c554140ea555d33928c1d12aae45/docarray/docarray/discussions/1749 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/166d24cf124d8e8e30b6fb92f162872f3320c554140ea555d33928c1d12aae45/docarray/docarray/discussions/1749 |
| og:image:alt | Hey there! Thanks for the great work! I am currently struggling a bit with the filter_docs: I have a docsList of a doc like this: class ImageDoc(BaseDoc): url: ImageUrl test_index: Optional[int] lo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | baa7d9900fdf7b27d604f36887af878d569cfbdcf97126832a5f4f0caf0c6ba5 |
| turbo-cache-control | no-preview |
| go-import | github.com/docarray/docarray git https://github.com/docarray/docarray.git |
| octolytics-dimension-user_id | 117445116 |
| octolytics-dimension-user_login | docarray |
| octolytics-dimension-repository_id | 438303578 |
| octolytics-dimension-repository_nwo | docarray/docarray |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 438303578 |
| octolytics-dimension-repository_network_root_nwo | docarray/docarray |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 842eff1d11f899d02b6b3b98fa3ea4860e64b34e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width