Hi team,
I am working on Weaviate hybrid search with filters and I want to match numeric values in queries with ingested data.
Example 1
-
Data: "The price of the apple is 80."
-
Query: "Show me items with price less than 90."
-
Filter: Filter.by_property("price").less_than(90)
-
I correctly get this record in the response.
Example 2
-
Data: "The price of the banana is between 50 and 80."
-
Now, I’m unsure how to store this information in the price
field.
-
If I store it as an array [50, 80]
, it won’t work with comparison operators like <
or >
.
-
But if I store just one number, I lose the range meaning.
Question: How should I ingest data in such cases where the property represents a range (e.g., 50–80), so that I can still apply filters effectively?
hi @Rohini_vaidya !!
You can filter with multi conditions. For example:
from weaviate.classes.query import Filter
response = collection.query.fetch_objects(
# Use & as AND
# | as OR
filters=(
Filter.by_property("price").greater_or_equal(50) &
Filter.by_property("price").less_or_equal(80)
),
limit=3
)
Is this what you are looking for?
THanks!
Hi @DudaNogueira ,
filters=( Filter.by_property(“price”).greater_or_equal(50) & Filter.by_property(“price”).less_or_equal(80) )
We can do it at query time.
However, I am now extracting the numbers from my data and ingesting them into a numerical field.
Now, for the record, “The price of the banana is between 50 and 80.”
The numbers extracted will be an array. In this case, how can I ingest it into a number field?
To apply the comparison filter, the data type must be int, not number_array.
so, my question is while ingesting data into weaviate how to store array of numbers ?