Hi all,
I currently have a problem using near_text with reference
I want to match my query with the reference chunk I have for example
response = building_collection.query.near_text(
query="Green garden city",
target_vector="buildingDetails", // namedVector in chunk class
filters=Filter.all_of(filter_array) if len(filter_array) > 0 else None,
limit=limit,
offset=offset,
return_references=[
QueryReference(
include_vector=True,
link_on="hasChunks"
),
],
)
this is my class definition
def create_buildings_vectordb_schema(client: WeaviateClient, logger: LoggerInterface) -> None:
collection_name = BUILDINGS_COLLECTION_NAME
if not client.collections.exists(collection_name):
new_collection = client.collections.create(
name=collection_name,
properties=[
wvc.config.Property(
name="buildingTitle",
data_type=wvc.config.DataType.TEXT,
vectorize_property_name=False,
skip_vectorization=True
),
wvc.config.Property(
name="buildingAddress",
data_type=wvc.config.DataType.TEXT,
vectorize_property_name=False,
skip_vectorization=True
),
wvc.config.Property(
name="buildingDescription",
data_type=wvc.config.DataType.TEXT,
vectorize_property_name=False,
skip_vectorization=True
),
wvc.config.Property(
name="housingPrice",
data_type=wvc.config.DataType.NUMBER,
vectorize_property_name=False,
skip_vectorization=True
),
wvc.config.Property(
name="ownerName",
data_type=wvc.config.DataType.TEXT,
vectorize_property_name=False,
skip_vectorization=True
),
wvc.config.Property(
name="ownerEmail",
data_type=wvc.config.DataType.TEXT,
vectorize_property_name=False,
skip_vectorization=True
),
wvc.config.Property(
name="ownerWhatsapp",
data_type=wvc.config.DataType.TEXT,
vectorize_property_name=False,
skip_vectorization=True
),
wvc.config.Property(
name="ownerPhoneNumber",
data_type=wvc.config.DataType.TEXT,
vectorize_property_name=False,
skip_vectorization=True
),
wvc.config.Property(
name="imageURL",
data_type=wvc.config.DataType.TEXT,
vectorize_property_name=False,
skip_vectorization=True
),
]
)
logger.log_info(f"Successfully create collection: {new_collection}")
this is my class chunk definition
def create_building_chunks_vectordb_schema(client: WeaviateClient, logger: LoggerInterface) -> None:
collection_name = BUILDING_CHUNKS_COLLECTION_NAME
if not client.collections.exists(collection_name):
new_collection = client.collections.create(
name=collection_name,
vectorizer_config=define_transformers(),
generative_config=define_generative(),
properties=[
wvc.config.Property(
name="chunk",
data_type=wvc.config.DataType.TEXT,
tokenization=wvc.config.Tokenization.WORD,
),
],
)
# the parent class collection
building_collection = client.collections.get(BUILDINGS_COLLECTION_NAME)
building_collection.config.add_reference(
wvc.config.ReferenceProperty(
name="hasChunks",
target_collection=BUILDING_CHUNKS_COLLECTION_NAME
)
)
logger.log_info(f"Successfully create collection: {new_collection}")
I have one chunk that has value of “This building located near Green garden city”, but the query result is not even similar at all
I actually tried to do the query from the chunk collection, it works but I need 2 or more reference similarity so I can perform query like, “Near Green garden and has maid cafe in it”
im sorry if this is confusing but I hope I get some enlightenment thanks