[Question] YOUR TOPIC

I created the collection like this

 wv_client.collections.create(
        name=class_name,
        description="collection_1",
        replication_config=Configure.replication(
            factor=1
        ),
        vectorizer_config=[
            Configure.Vectorizer.none()
        ],
        vector_index_config=Configure.VectorIndex.hnsw(
            distance_metric=VectorDistances.COSINE
        ),
        properties=[
            Property(name="product_no", data_type=DataType.NUMBER),
            Property(name="original_review", data_type=DataType.TEXT,
                     tokenization=Tokenization.WORD),
            Property(name="title", data_type=DataType.TEXT, skipVectorisation=True),
            Property(name="review", data_type=DataType.TEXT, skipVectorisation=True),
            Property(name="detail", data_type=DataType.TEXT, skipVectorisation=True),
        ]
    )

The title, review, and detail are multi-named vector fields, but I used the Configure.Vectorizer.none() option because I’m creating and putting in vector data directly

Example search

    col = client.collections.get(class_name)
    results = col.query.near_vector(near_vector=query_vector, limit=limit,
                                    return_properties=[“product_no”, “original_review”],
                                    include_vector=“True”,
                                    return_metadata=MetadataQuery(distance=True,
                                                                  creation_time=True),
                                    target_vector=“detail”)

If you proceed like this, you will get this error
“Query call with protocol GRPC search failed with message extract target vectors: class class_name does not have named vector detail configured. Available named vectors map.”

How do I fix it?

hi!

You never defined the named vectors to begin with :thinking:

Check here some nice academy we have about this:

this is how your collection should look like:

import weaviate
from weaviate import classes as wvc

client = weaviate.connect_to_local()

from weaviate import classes as wvc

client.collections.delete("MyCollection")
client.collections.create(
        name="MyCollection",
        description="collection_1",
        replication_config=wvc.config.Configure.replication(
            factor=1
        ),
        vectorizer_config=[
            wvc.config.Configure.NamedVectors.none(
                name="title",
            ),
            wvc.config.Configure.NamedVectors.none(
                name="review",
            ),
            wvc.config.Configure.NamedVectors.none(
                name="detail",
            ),
        ],
        properties=[
            wvc.config.Property(name="product_no", data_type=wvc.config.DataType.NUMBER),
            wvc.config.Property(name="original_review", data_type=wvc.config.DataType.TEXT,
                     tokenization=wvc.config.Tokenization.WORD),
            wvc.config.Property(name="title", data_type=wvc.config.DataType.TEXT, skipVectorisation=True),
            wvc.config.Property(name="review", data_type=wvc.config.DataType.TEXT, skipVectorisation=True),
            wvc.config.Property(name="detail", data_type=wvc.config.DataType.TEXT, skipVectorisation=True),
        ]
    )

Now inserting some data:

collection = client.collections.get("MyCollection")
collection.data.insert({
        "title": "This is a title",
        "detail": "some details",
        "review": "this seems good"
    },
    vector={
        "title": [1],
        "review": [1, 2],
        "detail": [1, 2, 3]
    }
)

and now retrieving it:

collection.query.fetch_objects(include_vector=True).objects[0].vector

and this should be the output:

{‘detail’: [1.0, 2.0, 3.0], ‘review’: [1.0, 2.0], ‘title’: [1.0]}

Let me know if this helps!!

Thanks!

1 Like