Help searching inside the objects in my weaviate

Hello,

I’m trying to implement a weaviate database with question and answers. My idea is to search if a particular question is already in the data base, and I’m using this code:

response = (
            client.query
            .get("Questions", ["answer","question", "technology"])
            .with_near_text({
                "concepts": [prompt],
                "distance": distance    
            })
            .with_where({
                "path": ["technology"],
                "operator": "Equal",
                "valueText": str(technology)
            })
            .with_additional(["id", "distance"])
            .with_limit(2)
            .do()
        )

Where “prompt” is the question that I want to introduce.

I’m using the distance parameter, but I only want to compare the distance of my questions, with the questions inside, not with the answers , it can be done? If yes… how?

Thanks!

hi @garcia.e !!

Whenever you do a nearText without a target_vector, you are comparing prompt against all vectorizable properties.

Not sure how your collection was created, but you have two options:

  1. Intentionally let only question property to be vectorizable, by setting all other properties to skip_vectorization=True
    with that, you only get 1 vector, that will be the representation of only your question.
  • Create a named vector only for your question, and when doing the nearText, specify that named vector as your target, as described here.
    You can have two named vectors. One for the entire object, and a second one for only the question property. Of course, this will double the usage of your embedding service, as for each object, it will vectorize it twice: one for all properties you point, and another one only for question.

Let me know if this helps :slight_smile:

Thanks!