Skip to content

Using QueryIterator with a RANDOM_SAMPLE(...) query causes pages after the first to fail #1721

@gehnaphore

Description

@gehnaphore

Version 2.6.6 of the Java SDK.

When QueryIterator is used with RANDOM_SAMPLE (seems like a common use case), all pages after the first get dropped with a message like this:

ERROR io.milvus.v2.utils.RpcUtils -- QueryRequest collectionName:radiology_cases failed, error code: 2, reason: failed to create query plan: cannot parse expression: ( RANDOM_SAMPLE(0.01773489873372823) ) and caseId > "cmg7ztvn32flo0764x2jg7tgo", error: random sample expression can only be the last expression in the logical and expression: invalid parameter

This is caused because QueryIterator.setupNextExpr() constructs a query that will be invalid if the oiriginal query uses RANDOM_SAMPLE, since if it is present it seemingly must be alone or the last component of a top-level conjunction.

It may be enough to change

return " ( "+currentExpr+" ) " + " and " + filteredPKStr;

to

return filteredPKStr + " and ( "+currentExpr+" ) ";

I will give this a try and submit a PR if it works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions