Equal filter on default TEXT property errors for stopword-only filter values
How to reproduce this bug?
Run reproduce.py against a local Weaviate server.
The script creates two collections containing the same data:
- A
TEXTpropertytagusing the default tokenization. - A
TEXTpropertytagusingTokenization.FIELD.
It inserts:
"a"
"the"
"alpha"
"b"and then runs:
Filter.by_property("tag").equal(value)for each value.
A minimal version of the relevant setup is:
from weaviate.classes.config import DataType, Property
from weaviate.classes.query import Filter
col = client.collections.create(
name="StopwordTest",
vectorizer_config=Configure.Vectorizer.none(),
properties=[
Property(name="tag", data_type=DataType.TEXT),
],
)
for tag in ["a", "the", "alpha", "b"]:
col.data.insert(
properties={"tag": tag},
vector=[0.0, 0.0],
)Then:
col.query.fetch_objects(
filters=Filter.by_property("tag").equal("a"),
limit=10,
)fails with a server-side error equivalent to:
invalid search term, only stopwords providedwhile:
col.query.fetch_objects(
filters=Filter.by_property("tag").equal("alpha"),
limit=10,
)succeeds.
As a control, defining the property as:
Property(
name="tag",
data_type=DataType.TEXT,
tokenization=Tokenization.FIELD,
)allows all four values, including "a" and "the", to be queried successfully with Equal.
What is the expected behavior?
Default TEXT and Tokenization.FIELD do not need to produce the same result set, because their tokenization semantics are intentionally different.
However, for a valid Equal filter value, query-side stopword removal should preferably not turn an otherwise valid filter request into a server-side query execution error.
Reasonable behaviors would include one of the following:
- The filter executes successfully and returns the result implied by the documented stopword/tokenization semantics.
- The filter executes successfully and returns no matches when the analyzed filter value contains no searchable terms.
- Stopword-only equality filters are explicitly documented as unsupported for default word-tokenized
TEXTproperties, including the fact that they produce an error rather than an empty result.
The main issue is that a normal stored string value can later become unqueryable through Equal because its query-side token sequence is reduced to zero terms.
What is the actual behavior?
With the default TEXT tokenization:
Equal("a") -> query error: only stopwords provided
Equal("the") -> query error: only stopwords provided
Equal("alpha") -> succeeds
Equal("b") -> succeedsWith Tokenization.FIELD:
Equal("a") -> succeeds
Equal("the") -> succeeds
Equal("alpha") -> succeeds
Equal("b") -> succeedsThe important distinction is that the default tokenization does not merely change which objects match. It changes a valid equality filter into a query execution error when the filter value consists entirely of stopwords.
Supporting information
Observed with:
- Weaviate 1.39.x local server
weaviate-client4.23.1- Local collection with no external vectorizer
- Python client v4
- Default inverted-index / stopword configuration
Server Version
Weaviate 1.39.x local
Weaviate Setup
Single Node
Nodes count
No response
Code of Conduct
- I have read and agree to the Weaviate's Contributor Guide and Code of Conduct
Source: weaviate/weaviate