You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
to query chunks with no elements in the "degree_programs" property (general documents) and, optionally, chunks about one of the specified degree programs. However, the first part of this filter causes an error:
File "/Users/michael/PycharmProjects/TUM_MGT_Chatbot/.venv/lib/python3.12/site-packages/weaviate/collections/filters.py", line 141, in __filter_to_int_list
if not isinstance(value, list) or not isinstance(value[0], int):
~~~~~^^^
IndexError: list index out of range
It seems that weaviate/collections/filters.py assumes (in several places) that any filter list will be non-empty. In my opinion this is not a reasonable assumption.
Hi @tsmith023, thanks for your response. Unfortunately the issue persists in filters.py - lines 108-111, 127, 134, 141, 207-217 all access value[0] without a length check.
I would open a PR to fix this myself, but lines 207-217 look problematic to me:
I am not familiar enough with the rest of this library (or with Python) to know what the best way to fix this would be. Does an empty list have any element type to speak of, and if not, how do we know what to return here?
Ahh, I see what you're driving at. Performing these types of filters actually isn't supported directly with your use-case by the core Weaviate server itself. Trying your same filtering syntax with the GraphQL API fails also.
However, you can achieve the same outcome by using a different logic instead. You can filter based on the length of a property and therefore achieve the desired response:
No problem! I think we can improve the error handling for an empty list here rather than having an index out of range error so I will open an issue to cover that
Activity
tsmith023 commentedon Mar 5, 2024
Hi Michael, this should be fixed by the latest
4.5.1release. LMK if it doesn't otherwise I will close this issue 😁MichaelOwenDyer commentedon Mar 5, 2024
Hi @tsmith023, thanks for your response. Unfortunately the issue persists in filters.py - lines 108-111, 127, 134, 141, 207-217 all access
value[0]without a length check.I would open a PR to fix this myself, but lines 207-217 look problematic to me:
I am not familiar enough with the rest of this library (or with Python) to know what the best way to fix this would be. Does an empty list have any element type to speak of, and if not, how do we know what to return here?
tsmith023 commentedon Mar 5, 2024
Ahh, I see what you're driving at. Performing these types of filters actually isn't supported directly with your use-case by the core Weaviate server itself. Trying your same filtering syntax with the GraphQL API fails also.
However, you can achieve the same outcome by using a different logic instead. You can filter based on the length of a property and therefore achieve the desired response:
LMK how that works for you!
P.S. To achieve this, your collection needs to have been configured with
index_property_length=Truein its inverted index config:MichaelOwenDyer commentedon Mar 5, 2024
Oh I see. That's very helpful, thank you!
tsmith023 commentedon Mar 5, 2024
No problem! I think we can improve the error handling for an empty list here rather than having an index out of range error so I will open an issue to cover that