Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what property/field is used when querying in weaviate

Tags:

weaviate

When we run queries on weaviate, what property the query is running on? Or is it running on all properties of each entry? Look at the following example, nearText is running on all three properties "question", "answer", "category" here? If that is the case, is there a way to specify a specific property to run the query on? For example, if I want to run nearText just on question, is there such a way?

import weaviate
import json

client = weaviate.Client(
    url="https://some-endpoint.weaviate.network/",  # Replace with your endpoint
    additional_headers={
        "X-OpenAI-Api-Key": "<THE-KEY>"  # Replace with your API key
    }
)

nearText = {"concepts": ["biology"]}

result = (
    client.query
    .get("Question", ["question", "answer", "category"])
    .with_near_text(nearText)
    .with_limit(2)
    .do()
)

print(json.dumps(result, indent=4))
like image 944
derek Avatar asked Nov 28 '25 19:11

derek


1 Answers

The with_near_text() is a pure vector search, translating the query into a vector embedding.

Weaviate knows what to vectorize based on your schema.

Take the following schema:

{
    "classes": [
        {
            "class": "Publication",
            "description": "A publication with an online source",
            "moduleConfig": {
                "text2vec-transformers": {
                    "poolingStrategy": "masked_mean",
                    "vectorizeClassName": false
                }
            },
            "properties": [
                {
                    "dataType": [
                        "string"
                    ],
                    "description": "Name of the publication",
                    "moduleConfig": {
                        "text2vec-transformers": {
                            "skip": false,
                            "vectorizePropertyName": false
                        }
                    },
                    "name": "name",
                    "tokenization": "word"
                }
            ],
            "vectorizer": "text2vec-transformers"
        }
    ]
}

Note the "text2vec-transformers": { "skip": false, "vectorizePropertyName": false } section.

This says that it will not skip (because skip: false the property when creating a vector).

In other words, the vector is based on the property name.

It's explained in a bit more detail here: https://weaviate.io/developers/weaviate/tutorials/schema#class-property-specification-examples

like image 62
Bob van Luijt Avatar answered Dec 02 '25 03:12

Bob van Luijt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!