milvus-io / milvus-sdk-go

Go SDK for Milvus.
Apache License 2.0
326 stars 105 forks source link

[Bug]: Enforcing limit on search doesn't work #775

Open mdmmn378 opened 2 months ago

mdmmn378 commented 2 months ago

Is there an existing issue for this?

Current Behavior

When I attempt to enforce a limit to vector search, it doesn't work and returns the full-length result. image

Expected Behavior

When I enforce a limit explicitly, it should return the exact number of results, not more.

Steps To Reproduce

I used IVF_PQ INDEX_TYPE with the following configuration.

// Constants
const (
    N_PROBE    = 128
    N_LIST     = 4096
    N_BITS     = 8
    M          = 16
    VECTOR_DIM = 384
)

const (
    L2     MetricType = "L2"
    IP     MetricType = "IP"
    Cosine MetricType = "COSINE"
)

var ConsistencyLevel = entity.ClEventually

Here is the schema
```go

var COLLECTION_SCHEMA = entity.NewSchema().WithName(COLLECTION_NAME).WithDescription("this is the example collection for insert and search").
    WithField(entity.NewField().WithName("id").WithDataType(entity.FieldTypeVarChar).WithIsPrimaryKey(true).WithIsAutoID(false).WithMaxLength(128)).
    WithField(entity.NewField().WithName("vector").WithDataType(entity.FieldTypeFloatVector).WithDim(VECTOR_DIM)).
    WithField(entity.NewField().WithName("tag").WithDataType(entity.FieldTypeVarChar).WithMaxLength(128))


### Environment

_No response_

### Anything else?

_No response_
ThreadDao commented 1 month ago

@congqixia Please help take a look. @mdmmn378 image It is recommended to use topk as the approximate number of vectors expected to be returned by the search.

mdmmn378 commented 1 month ago

Thanks for your comment. I understand the role of topk. But, what's the exact role of limit here?