It is for an e-commerce use case.
We sell products and products have different properties depending on the city, e.g. price, availability etc.. When we query for a product, we always want to filter with a city and only want to return information for that city.
Within Weaviate I built 2 classes City and Product.
class Product:
brand: string
picture: string
cities: List[city]
class City:
cityId: String
additionalInfo: String
I can't seem to find a way to query Weaviate so that it returns only the reference/data to the single matching city. Instead, it returns the product and information for all cities. Below is the query I am using.
{
Get {
Product(
where: {
operator: And
operands: [
{
path: ["cities", "City", "cityId"]
operator: Equal
valueString: "12121"
}
{ path: ["brand"], operator: Equal, valueString: "Goro" }
]
}
nearVector: { vector: [1, 1, 1, 1] }
) {
sku
responseBody
cities {
... on City {
CityId
additionalInfo
}
}
}
}
}
Can someone suggest a way that I could improve on the query to return only a single city? If this is not possible, could someone suggest a better schema to achieve what I am looking for?
I will explain how the query you wrote is actually interpreted.
Let's call this part of the query
A
:A
will return all Products where the cityId is 12121Let's call this part of the query
B
:B
will return all Products where the brand is Goro.A
And
B
will return the products that are common to bothA
andB
so the final result is just Goro branded products.There's already an issue to support a new query syntax that will produce the result you want. Here's the issue: https://github.com/semi-technologies/weaviate/issues/2477
Would be great if you can upvote it so that weaviate team can prioritise it accordingly.