run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
35.41k stars 4.99k forks source link

[Bug]: WeaviateVectorStore uses broken filter #15743

Open ndettmer opened 2 weeks ago

ndettmer commented 2 weeks ago

Bug Description

When querying a WeaviateVectorStore based on a VectorStoreIndex that holds node_ids, the Weaviate server throws an error "no such prop with name 'id' found in class"

The cause of this error might be the filter in the query function that is looking for the "id" property, while the deafult schema's properties don't have this field.

Version

0.11.2

Steps to Reproduce

  1. Create an Index using a WeaviateVectorStore and an IndexStore (I used PostgreSQL).
  2. Fill the Index with nodes.
  3. Load the Index from the IndexStore.
  4. Perform a query on the index.

Relevant Logs/Tracbacks

AioRpcError: <AioRpcError of RPC that terminated with:
    status = StatusCode.UNKNOWN
    details = "no such prop with name 'id' found in class 'W_b4ae0a5153e0eaecd4b67a84b30b5da1151f97f77b6ceabde7c03d7536c46bc0' in the schema. Check your schema files for which properties in this class are available"
    debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2024-08-30T14:59:37.704081411+02:00", grpc_status:2, grpc_message:"no such prop with name \'id\' found in class \'W_b4ae0a5153e0eaecd4b67a84b30b5da1151f97f77b6ceabde7c03d7536c46bc0\' in the schema. Check your schema files for which properties in this class are available"}"
>
...
ValueError: Invalid query, got errors: <AioRpcError of RPC that terminated with:
    status = StatusCode.UNKNOWN
    details = "no such prop with name 'id' found in class 'W_b4ae0a5153e0eaecd4b67a84b30b5da1151f97f77b6ceabde7c03d7536c46bc0' in the schema. Check your schema files for which properties in this class are available"
    debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2024-08-30T14:59:37.704081411+02:00", grpc_status:2, grpc_message:"no such prop with name \'id\' found in class \'W_b4ae0a5153e0eaecd4b67a84b30b5da1151f97f77b6ceabde7c03d7536c46bc0\' in the schema. Check your schema files for which properties in this class are available"}"
>
dosubot[bot] commented 2 weeks ago

Hello @ndettmer! I'm here to help you with any bugs, questions, or contributions you have regarding the repository. If you need any assistance, feel free to ask.

I found a similar closed issue: [Question]: Can't get metadata from weaviate. The suggested solution was to change the structure of the filter, including the path and the value [1].

The error "no such prop with name 'id' found in class" occurs because the property name 'id' does not exist in the Weaviate class schema. The correct property name should be used instead.

In the query method, when filtering with node IDs, the code uses the path ["id"]:

if query.node_ids:
    filter_with_node_ids = {
        "operator": "Or",
        "operands": [
            {"path": ["id"], "operator": "Equal", "valueText": node_id}
            for node_id in query.node_ids
        ],
    }
    query_builder = query_builder.with_where(filter_with_node_ids)

However, the property name 'id' is not a valid property in the Weaviate schema. You should use the correct property name that corresponds to the node ID in your schema. For example, if the node ID is stored under the property name 'node_id', you should modify the path accordingly:

if query.node_ids:
    filter_with_node_ids = {
        "operator": "Or",
        "operands": [
            {"path": ["node_id"], "operator": "Equal", "valueText": node_id}
            for node_id in query.node_ids
        ],
    }
    query_builder = query_builder.with_where(filter_with_node_ids)

Make sure to replace "node_id" with the actual property name used in your Weaviate schema for node IDs [2].

To continue talking to Dosu, mention @dosu.

logan-markewich commented 2 weeks ago

I think most people don't hit this bug because they don't use an index store (just the vector store is all you really need)