-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Open
Labels
Description
Bug Description
After updating llama index from 0.8.50 to 0.9.35 my vector query broke. MetadataFilters that use strings containing numeric values throw error complaining that valueNumber does not match valueText
Version
0.9.35
Steps to Reproduce
All you have to do is have a numeric string value in a metadata filter against a valueText field and the error will occur.
Seems to be a result of
| elif isinstance(filter.value, str) and filter.value.isnumeric(): |
import weaviate
from llama_index.schema import TextNode
from llama_index.vector_stores.weaviate import WeaviateVectorStore
from llama_index.vector_stores.types import MetadataFilters, MetadataFilter, VectorStoreQuery
client = weaviate.Client(url="http://localhost:8080")
vector_store = WeaviateVectorStore(weaviate_client=client, index_name="TestIndex", text_key="text")
vector_store.add(
[
TextNode(
text="test 1",
metadata={"article_id": "aaff"},
embedding=[0, 0, 1],
),
TextNode(
text="test 2",
metadata={"article_id": "1234"},
embedding=[0, 1, 0],
),
TextNode(
text="test 3",
metadata={"article_id": "3ff3"},
embedding=[1, 0, 0],
)
]
)
# -- working query
query = VectorStoreQuery(
query_embedding=[0, 0, 0],
similarity_top_k=2,
filters=MetadataFilters(
filters=[
MetadataFilter(key="article_id", value="3ff3") # NOTE: works fine because is not a number
]
)
)
results = vector_store.query(query)
print(results)
# -- below query breaks
query = VectorStoreQuery(
query_embedding=[0, 0, 0],
similarity_top_k=2,
filters=MetadataFilters(
filters=[
MetadataFilter(key="article_id", value="1234") # NOTE: breaks because it's a number but the metadata field is a text field
]
)
)
results = vector_store.query(query)
print(results)Relevant Logs/Tracbacks
results = vector_store.query(query)
File "/usr/local/lib/python3.10/site-packages/llama_index/vector_stores/weaviate.py", line 338, in query
parsed_result = parse_get_response(query_result)
File "/usr/local/lib/python3.10/site-packages/llama_index/vector_stores/weaviate_utils.py", line 65, in parse_get_response
raise ValueError("Invalid query, got errors: {}".format(response["errors"]))
ValueError: Invalid query, got errors: [{'locations': [{'column': 6, 'line': 1}], 'message': 'invalid \'where\' filter: child operand at position 0: data type filter cannot use "valueNumber" on type "text", use "valueText" instead', 'path': ['Get', 'User91609c28065a470e96c78465a7f40d6dReport1']}]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status