Determine if a query response was cut off

Description

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.

Server Setup Information

  • Weaviate Server Version: 1.26.1
  • Deployment Method: k8s
  • Multi Node? Number of Running Nodes: 3
  • Client Language and Version: Python 3, latest
  • Multitenancy?: No

Just want to bump this, in case there is something obvious I’m missing.

hi @elias.gabriel !!

Sorry for the delay here, had some vacation last weeks :mountain: :beach_umbrella:

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.

Here we have a nice explanation about it

Now, let’s see it in action!

consider this code:

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.

Let me know if this clarifies.

Thanks!

Hi @DudaNogueira,

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.

Oh, ok. Now I understand it! I was totally off, hehehe

That’s strange, as it only returned 44, if no limits are defined.

here simpler code to reproduce:

client.collections.delete("Test")
collection = client.collections.create(
    name="Test",
    vectorizer_config=wvc.config.Configure.Vectorizer.none(),
)

response = collection.data.insert_many([{"index": i} for i in range(200)])
inserted_uids_count = len(response.uuids.values())

query = collection.query.fetch_objects(
            filters=wvc.query.Filter.by_id().contains_any(response.uuids.values()),
            # limit=200
        )
assert len(query.objects) == inserted_uids_count

however, if we specify a limit, it will work.

This smells like a bug to me. I have asked about this internally.

I’ll get back here when I get more info.

Thanks!

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?

Oh, by the way, my outcome was using a docker image.

Ah!!! just checked, silly me. hehehe

Because I have reused a docker-compose.yaml I have in my “lab” folder, I had QUERY_DEFAULTS_LIMIT set to 44… :see_no_evil:

So if I remove that property, the query will result by default in 10, which is consistent with the doc here

So I query_defaults is the same as QUERY_DEFAULTS_LIMIT.

Now if you know the QUERY_DEFAULTS_LIMIT, and your results is exactly that value, you probably have more objects