Quantcast
Channel: Weaviate Community Forum - Latest posts
Viewing all articles
Browse latest Browse all 3601

Conditional filter with python client v4

$
0
0

hi @jhc !!

Welcome to our community :hugs:

This is certainly possible.

here is how:

import weaviate
client = weaviate.connect_to_local()
from weaviate.classes.query import Filter

client.collections.delete("Test")
collection = client.collections.create(name="Test")
collection.data.insert({"color": "grau", "price": 300})
collection.data.insert({"color": "grau", "price": 400})
collection.data.insert({"color": "grau", "price": 100})
collection.data.insert({"color": "bope", "price": 400})
collection.data.insert({"color": "bope", "price": 200})

# now we filter

query = collection.query.fetch_objects(
    filters=(
        Filter.by_property("color").equal("grau") & 
        Filter.by_property("price").less_or_equal(300)
    )
)
for object in query.objects:
    print(object.properties)

For more information on filters, check this doc:

Let me know if this helps!

Thanks!


Viewing all articles
Browse latest Browse all 3601

Trending Articles