2

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))
derek
  • 9,358
  • 11
  • 53
  • 94

1 Answers1

1

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

Bob van Luijt
  • 7,153
  • 12
  • 58
  • 101