milvus-io / milvus-sdk-go

Go SDK for Milvus.
Apache License 2.0
347 stars 109 forks source link

[Bug]: Create sparse index with different ways gets different default index name #726

Closed ThreadDao closed 4 months ago

ThreadDao commented 6 months ago

Is there an existing issue for this?

Current Behavior

image: master-20240415-fd971a43-amd64 sdk: go-master

  1. create sparse index with entity.NewGenericIndex gets default index name: vector field name
  2. create sparse index with entity.NewIndexSparseInverted gets default index name: SparseInverted
    
    2024/04/17 11:18:05 index_test.go:702: sparseVec SPARSE_INVERTED_INDEX map[drop_ratio_build:0.2 index_type:SPARSE_INVERTED_INDEX metric_type:IP]

2024/04/17 11:18:15 index_test.go:702: SparseInverted SPARSE_INVERTED_INDEX map[index_type:SPARSE_INVERTED_INDEX metric_type:IP params:{"drop_ratio_build":"0.2"}]


case:

func TestCreateIndexSparseVector(t *testing.T) { t.Parallel() idxInverted := entity.NewGenericIndex(common.DefaultSparseVecFieldName, "SPARSE_INVERTED_INDEX", map[string]string{"drop_ratio_build": "0.2", "metric_type": "IP"}) idxWand := entity.NewGenericIndex(common.DefaultSparseVecFieldName, "SPARSE_WAND", map[string]string{"drop_ratio_build": "0.3", "metrictype": "IP"}) idxInverted1, := entity.NewIndexSparseInverted(entity.IP, 0.2) idxWand1, _ := entity.NewIndexSparseWAND(entity.IP, 0.3)

for _, idx := range []entity.Index{idxInverted, idxWand, idxInverted1, idxWand1} {
    ctx := createContext(t, time.Second*common.DefaultTimeout)
    //connect
    mc := createMilvusClient(ctx, t)

    // create collection with all datatype
    cp := CollectionParams{CollectionFieldsType: Int64VarcharSparseVec, AutoID: false, EnableDynamicField: true,
        ShardsNum: common.DefaultShards, Dim: common.DefaultDim, MaxLength: 300}
    collName := createCollection(ctx, t, mc, cp)

    // insert
    dp := DataParams{CollectionName: collName, PartitionName: "", CollectionFieldsType: Int64VarcharSparseVec,
        start: 0, nb: common.DefaultNb, dim: common.DefaultDim, EnableDynamicField: true, WithRows: false}
    _, _ = insertData(ctx, t, mc, dp, common.WithSparseVectorLen(100))
    mc.Flush(ctx, collName, false)

    // create index
    err := mc.CreateIndex(ctx, collName, common.DefaultSparseVecFieldName, idx, false)
    common.CheckErr(t, err, true)

    // describe index
    idx2, err := mc.DescribeIndex(ctx, collName, common.DefaultSparseVecFieldName)
    log.Println(idx.Name(), idx.IndexType(), idx.Params())
    log.Println(idx2[0].Name(), idx2[0].IndexType(), idx2[0].Params())
    common.CheckErr(t, err, true)
    common.CheckIndexResult(t, idx2, idx)
}

}



### Expected Behavior

_No response_

### Steps To Reproduce

_No response_

### Environment

_No response_

### Anything else?

_No response_
ThreadDao commented 6 months ago

/assign @congqixia

siddarth99 commented 4 months ago

@ThreadDao @congqixia Can I work on this issue if it hasn't been picked yet?

congqixia commented 4 months ago

@siddarth99 sure /assign @siddarth99 /unassign

ThreadDao commented 4 months ago

server 2.5 Supports autoIndex of fields other than Array and Json

ThreadDao commented 4 months ago

fixed