Skip to content

Commit f839a49

Browse files
Milvus-doc-botMilvus-doc-bot
authored andcommitted
Release new docs to master
1 parent 6995130 commit f839a49

File tree

1 file changed

+92
-19
lines changed

1 file changed

+92
-19
lines changed

v2.6.x/site/en/userGuide/search-query-get/multi-vector-search.md

Lines changed: 92 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ client = MilvusClient(
6969
)
7070

7171
# Init schema with auto_id disabled
72-
schema = MilvusClient.create_schema(auto_id=False)
72+
schema = client.create_schema(auto_id=False)
7373

7474
# Add fields to schema
7575
schema.add_field(field_name="id", datatype=DataType.INT64, is_primary=True, description="product id")
@@ -247,7 +247,7 @@ const functions = [
247247
output_field_names: ["text_sparse"],
248248
params: {},
249249
},
250-
]
250+
];
251251
```
252252

253253
```bash
@@ -319,8 +319,6 @@ You can choose other index types as necessary to best suit your needs and data t
319319
</div>
320320

321321
```python
322-
from pymilvus import MilvusClient
323-
324322
# Prepare index parameters
325323
index_params = client.prepare_index_params()
326324

@@ -453,8 +451,6 @@ Create a collection named `demo` with the collection schema and indexes configur
453451
</div>
454452

455453
```python
456-
from pymilvus import MilvusClient
457-
458454
client.create_collection(
459455
collection_name="my_collection",
460456
schema=schema,
@@ -529,26 +525,30 @@ Since this example uses the built-in BM25 function to generate sparse embeddings
529525
</div>
530526

531527
```python
532-
from pymilvus import MilvusClient
528+
import random
529+
530+
# Generate example vectors
531+
def generate_dense_vector(dim):
532+
return [random.random() for _ in range(dim)]
533533

534534
data=[
535535
{
536536
"id": 0,
537537
"text": "Red cotton t-shirt with round neck",
538-
"text_dense": [0.3580376395471989, -0.6023495712049978, 0.18414012509913835, ...],
539-
"image_dense": [0.6366019600530924, -0.09323198122475052, ...]
538+
"text_dense": generate_dense_vector(768),
539+
"image_dense": generate_dense_vector(512)
540540
},
541541
{
542542
"id": 1,
543543
"text": "Wireless noise-cancelling over-ear headphones",
544-
"text_dense": [0.19886812562848388, 0.06023560599112088, 0.6976963061752597, ...],
545-
"image_dense": [0.6414180010301553, 0.8976979978567611, ...]
544+
"text_dense": generate_dense_vector(768),
545+
"image_dense": generate_dense_vector(512)
546546
},
547547
{
548548
"id": 2,
549549
"text": "Stainless steel water bottle, 500ml",
550-
"dense": [0.43742130801983836, -0.5597502546264526, 0.6457887650909682, ...],
551-
"image_dense": [-0.6901259768402174, 0.6100500332193755, ...]
550+
"text_dense": generate_dense_vector(768),
551+
"image_dense": generate_dense_vector(512)
552552
}
553553
]
554554

@@ -680,8 +680,8 @@ To demonstrate the capabilities of various search vector fields, we will constru
680680
from pymilvus import AnnSearchRequest
681681

682682
query_text = "white headphones, quiet and comfortable"
683-
query_dense_vector = [0.3580376395471989, -0.6023495712049978, 0.5142999509918703, ...]
684-
query_multimodal_vector = [0.015829865178701663, 0.5264158340734488, ...]
683+
query_dense_vector = generate_dense_vector(768)
684+
query_multimodal_vector = generate_dense_vector(512)
685685

686686
# text semantic search (dense)
687687
search_param_1 = {
@@ -820,10 +820,85 @@ Given that the parameter `limit` is set to 2, each `AnnSearchRequest` returns 2
820820

821821
### Step 2: Configure a reranking strategy
822822

823-
To merge and rerank the sets of ANN search results, selecting an appropriate reranking strategy is essential. Milvus offers several types of reranking strategies. For more details on these reranking mechanisms, please refer to [Reranking](reranking).
823+
To merge and rerank the sets of ANN search results, selecting an appropriate reranking strategy is essential. Milvus offers several types of reranking strategies. For more details on these reranking mechanisms, please refer to [Weighted Ranker](weighted-ranker.md) or [RRF Ranker](rrf-ranker.md).
824824

825825
In this example, since there is no particular emphasis on specific search queries, we will proceed with the RRFRanker strategy.
826826

827+
<div class="multipleCode">
828+
<a href="#python">Python</a>
829+
<a href="#java">Java</a>
830+
<a href="#javascript">NodeJS</a>
831+
<a href="#go">Go</a>
832+
<a href="#bash">cURL</a>
833+
</div>
834+
835+
```python
836+
ranker = Function(
837+
name="rrf",
838+
input_field_names=[], # Must be an empty list
839+
function_type=FunctionType.RERANK,
840+
params={
841+
"reranker": "rrf",
842+
"k": 100 # Optional
843+
}
844+
)
845+
```
846+
847+
```java
848+
import io.milvus.common.clientenum.FunctionType;
849+
import io.milvus.v2.service.collection.request.CreateCollectionReq.Function;
850+
851+
Function ranker = Function.builder()
852+
.name("rrf")
853+
.functionType(FunctionType.RERANK)
854+
.param("reranker", "rrf")
855+
.param("k", "100")
856+
.build()
857+
```
858+
859+
```javascript
860+
const rerank = {
861+
name: 'rrf',
862+
description: 'bm25 function',
863+
type: FunctionType.RERANK,
864+
input_field_names: [],
865+
params: {
866+
"reranker": "rrf",
867+
"k": 100
868+
},
869+
};
870+
```
871+
872+
```go
873+
import (
874+
"github.com/milvus-io/milvus/client/v2/entity"
875+
)
876+
877+
ranker := entity.NewFunction().
878+
WithName("rrf").
879+
WithType(entity.FunctionTypeRerank).
880+
WithParam("reranker", "rrf").
881+
WithParam("k", "100")
882+
```
883+
884+
```bash
885+
# Restful
886+
export functionScore='{
887+
"functions": [
888+
{
889+
"name": "rrf",
890+
"type": "Rerank",
891+
"inputFieldNames": [],
892+
"params": {
893+
"reranker": "rrf",
894+
"k": 100
895+
}
896+
}
897+
]
898+
}'
899+
900+
```
901+
827902
### Step 3: Perform a Hybrid Search
828903

829904
Before initiating a Hybrid Search, ensure that the collection is loaded. If any vector fields within the collection lack an index or are not loaded into memory, an error will occur upon executing the Hybrid Search method.
@@ -837,8 +912,6 @@ Before initiating a Hybrid Search, ensure that the collection is loaded. If any
837912
</div>
838913

839914
```python
840-
from pymilvus import MilvusClient
841-
842915
res = client.hybrid_search(
843916
collection_name="my_collection",
844917
reqs=reqs,
@@ -904,7 +977,7 @@ const search = await client.search({
904977

905978
```bash
906979
curl --request POST \
907-
--url "${CLUSTER_ENDPOINT}/v2/vectordb/entities/advanced_search" \
980+
--url "${CLUSTER_ENDPOINT}/v2/vectordb/entities/hybrid_search" \
908981
--header "Authorization: Bearer ${TOKEN}" \
909982
--header "Content-Type: application/json" \
910983
-d "{

0 commit comments

Comments
 (0)