Hi, i’m running into unexpected behavior when combining hybrid search with a date-range filter. When I filter for a range in which no objects exist, the filter seems to be silently dropped and I get back all results—as if no filter were applied. However, when I filter for a range that does contain data, the filter works correctly.
I’m using the Python client and have a class ArtikelChunks
with a publishdate
property (DateTime). All of my data live in March 2025.
Here a code sample to reproduce:
import datetime
import weaviate
from weaviate.classes.query import Filter
from zoneinfo import ZoneInfo
start_date = datetime.datetime(2025, 5, 1).replace(tzinfo=ZoneInfo("Europe/Berlin"))
end_date = datetime.datetime(2025, 5, 15).replace(tzinfo=ZoneInfo("Europe/Berlin"))
if start_date.date() == end_date.date():
next_day = start_date + datetime.timedelta(days=1)
date_filter = (
Filter.by_property("publishdate").greater_or_equal(start_date)
& Filter.by_property("publishdate").less_than(next_day)
)
else:
date_filter = (
Filter.by_property("publishdate").greater_or_equal(start_date)
& Filter.by_property("publishdate").less_or_equal(end_date)
)
client = weaviate.connect_to_local(headers={"X-OpenAI-Api-Key": embeddings_api_key})
chunks_collection = client.collections.get("ArtikelChunks")
response = chunks_collection.query.hybrid(
query="whatever",
limit=5,
filters=date_filter,
)
print("Start Date:", start_date)
print("End Date: ", end_date, "\n")
for o in response.objects:
print("publishdate:", o.properties.get("publishdate"))
client.close()
Output for May 1–15, 2025 (no data in that window):
Start Date: 2025-05-01 00:00:00+02:00
End Date: 2025-05-15 00:00:00+02:00
publishdate: 2025-03-05 06:23:00+01:00
publishdate: 2025-03-12 14:30:00+01:00
publishdate: 2025-03-18 09:15:00+01:00
publishdate: 2025-03-26 17:50:00+01:00
publishdate: 2025-03-30 22:05:00+01:00
… (all March dates)
Output for Mar 1–15, 2025 (data exists):
Start Date: 2025-03-01 00:00:00+01:00
End Date: 2025-03-15 00:00:00+01:00
publishdate: 2025-03-13 18:46:36+01:00
publishdate: 2025-03-09 18:00:00+01:00
publishdate: 2025-03-14 16:22:09+01:00
publishdate: 2025-03-01 09:02:00+01:00
publishdate: 2025-03-09 19:12:10+01:00
… (correctly only March 1–15)
Questions
- Is it expected behavior that when a hybrid query’s filter matches zero objects, the filter is ignored and all objects are returned?
- If not, how can I enforce a “no-matches → empty result set” semantic when filtering on a date range with hybrid search?
Any pointers or workarounds would be appreciated.
Server Setup Information
- Weaviate Server Version:
- Deployment Method:
- Multi Node? Number of Running Nodes:
- Client Language and Version:
- Multitenancy?: