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

Conditional filter with python client v4

$
0
0

Let me try once more.

In python client v3, I could query weaviate with a filter that consists of python data structures, e.g.

filter_in_python_data_structures = {‘operator’: ‘And’, ‘operands’: [{‘path’: [‘price’], ‘operator’: ‘LessThanEqual’, ‘valueNumber’: 300}, {‘path’: [‘color’], ‘operator’: ‘Equal’, ‘valueText’: ‘schwarz’}, {‘path’: [‘available_sizes’], ‘operator’: ‘Like’, ‘valueText’: ‘44’}, {‘path’: [‘categories’], ‘operator’: ‘Like’, ‘valueText’: ‘Schuhe’}, {‘path’: [‘material’], ‘operator’: ‘Like’, ‘valueText’: ‘Leder’}, {‘path’: [‘brand’], ‘operator’: ‘Equal’, ‘valueText’: ‘Nike’}, {‘path’: [‘certifications’], ‘operator’: ‘Like’, ‘valueText’: ‘Öko-Tex Standard 100’}, {‘path’: [‘condition’], ‘operator’: ‘Equal’, ‘valueText’: ‘neu’}] … }

This filter is long and complex. It is build by another module.

In python client v3, I could query weaviate with directly using this filter:

client.query.get(collection, return_properties).with_where(filter_in_python_data_structures)

But, in python client v4, there is no “with_where” method anymore. I found the methods you indicated, but they would not accept something like filter_in_python_data_structures.
Instead, that is my understanding, I need to build a filter by myself with Filter.by_property etc.

But, I don’t like to do that, as would need to write first a wrapper to transform filter_in_python_data_structures to something that is accepted by collection.query.fetch_objects( filters=…) .
Before doing that, I would rather translate filter_in_python_data_structures to a valid graphQL string and call weaviate without making use of the python client.

My hope is, that I have overlooked something, and that there is a way to still query as it was possible in python client v3. Or, if not, maybe, you are planning to extend the functionality of python client v4 in this way.


Viewing all articles
Browse latest Browse all 3605

Trending Articles