milvus-io / milvus-sdk-node

The Official Mivus node.js sdk(client)
https://milvus.io
Apache License 2.0
127 stars 39 forks source link

Please support search for multiple vectors #260

Closed ShravanSunder closed 5 months ago

ShravanSunder commented 11 months ago

Describe the feature:

the client should support search for multiple vectors See https://github.com/milvus-io/milvus/issues/25639

Describe a specific use case for the feature: Some collection need multiple vectors to represent them. The should be indexable and searchable.

shanghaikid commented 11 months ago

I think you can search with mulitple vectors.

client.search({
  collection_name: 'my_collection',
  data: [vector1, vector2],
  limit: 5
 }) ;
shanghaikid commented 11 months ago

Well, the current Node SDK allows you to search multiple vectors across an entire collection. However, the feature you're referring to, where a single collection can have two or more vector fields, is not yet available. Please stay tuned for the upcoming release of Milvus. : )

shanghaikid commented 5 months ago

2.4 version has been released.

import { RRFRanker, WeightedRanker } from '@zilliz/milvus2-sdk-node';
// single-vector search on a collection with multiple vector fields
const search = await milvusClient.search({
  collection_name: collection_name,
  data: [1, 2, 3, 4, 5, 6, 7, 8],
  anns_field: 'vector', // required if you have multiple vector fields in the collection
  params: { nprobe: 2 },
  filter: 'id > 100',
  limit: 5,
});

// multi-vector search on a collection with multiple vector fields
const search = await milvusClient.search({
  collection_name: collection_name,
  data: [
    {
      data: [1, 2, 3, 4, 5, 6, 7, 8],
      anns_field: 'vector',
      params: { nprobe: 2 },
    },
    {
      data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
      anns_field: 'vector1',
    },
  ],
  limit: 5,
  rerank: RRFRanker(),
  filter: 'id > 100',
});

You can check the test case: https://github.com/milvus-io/milvus-sdk-node/blob/main/test/grpc/MultipleVectors.spec.ts