How to use filter_docs with multiple filter from the same key (bug?) #1749
-
Hey there! 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]
local_path: Optional[str]
tensor: Optional[ImageTorchTensor]
embedding: Optional[AnyEmbedding] Now 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:
And 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. What would be the correct approach for this? Currently I am solving this with a regex expression, but that does not seem right haha |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
This could be a bug. When using different keys in the same and clause, it works? |
Beta Was this translation helpful? Give feedback.
-
Seems like a bug, will open an issue referencing this discussion |
Beta Was this translation helpful? Give feedback.
-
Hello @simonschoenhofen . I finally got time to look at this issue. This 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. I would say that the query should be designed differently using the query = { |
Beta Was this translation helpful? Give feedback.
Hello @simonschoenhofen .
I finally got time to look at this issue.
This 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.
I would say that the query should be designed differently using the
nin
(not in a set) clause:query = {
'test_index' : {'$nin' : [3, 9]},
}