I see that there’s a limit on the number of results that can be returned by a query - on K8 deployments, looks like that limit is 100 by default.
The default behavior is just to cut off the response at that limit; regardless of whether or not there could be more results.
Is there a way to tell if a query response was cut off? otherwise it seems really difficult to diagnose problems where returned results don’t meet expectations (or worse, things fly under the radar) — i say that having not known about the limit, encountering problems with missing response data, and spending a while trying to figure out what’s going on
In any case, a documentation update would also be useful to explain the behavior.
Sorry for the delay here, had some vacation last weeks
I am not sure yet what that 100 limit is about, but it definitely isn’t a Weaviate configuration. Probably a K8s one. Could not find much info about it, TBH.
Here is where you define the QUERY_MAXIMUM_RESULTS:
The outcut will only jump in if you explicitly call it.
client.collections.delete("Test")
collection = client.collections.create(
name="Test",
vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_openai(),
)
collection.data.insert_many([
{"text": "something about dogs"},
{"text": "something about cats"},
{"text": "something about houses"},
{"text": "something about commercial buildings"},
])
Now, if I do a query, without outcut, I get everything:
results = collection.query.near_text(
query="animals",
# auto_limit=2,
return_metadata=wvc.query.MetadataQuery(distance=True)
)
for i in results.objects:
print("###")
print(i.properties)
print(i.metadata.distance)
the results:
{‘text’: ‘something about dogs’}
0.16042447090148926
{‘text’: ‘something about cats’}
0.17177188396453857
{‘text’: ‘something about houses’}
0.22456467151641846
{‘text’: ‘something about commercial buildings’}
0.23881018161773682
If I now add auto_limit=1, it will only bring the dogs and cats object. If set it to 2, it will bring me all objects.
I made a small example to clarify what I’m talking about:
I span up a minikube cluster on my machine, and installed the latest weaviate helm chart using a really simple config and all the chart defaults (including the env variable you mention).
If you create a basic collection, then add 200 objects, then query for all those objects using the created uuids, it only returns 100 of them; there is no indication that the query response was incomplete.
Huh, that’s interesting; your snippet only ever returns 100 for me, same as the one I provided, not 44; that seems like a bug in itself.
If I update the query_defaults.limit parameter in the chart values to 150, the query then returns 150, so that chart configuration (which looks like gets mounted to a YAML configuration and passed through to weaviate --config-file), is definitely responsible for the behavior.
You are right, though, in that if I explicitly pass a limit to the query then I get all 200 objects as expected; I guess that makes sense given that the config seems to imply its the “default limit for queries that don’t supply one.”
If that is indeed the behavior, then my original question is more like “is there a way to tell if a query hit the limit (default or provided) or not?”
Also I want to emphasize that I can’t actually reproduce this problem using a Docker Compose setup, even if I supply the helm-produced yaml config to weaviate via the same CLI argument. It’s only in K8 deployments. If the default limit thing is an intended feature, then the fact it doesn’t work on Docker depls seems like another bug?