tencent cloud

Elasticsearch Service

문서Elasticsearch ServiceVector Search GuideVector SearchVector Search (Single-Vector and Multi-Vector)

Vector Search (Single-Vector and Multi-Vector)

Download
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-08-12 18:13:52
AI 번역
This document introduces the key points of k-nearest neighbor (kNN) search. For more details, refer to the related document.

Single-Vector Search

This is the most basic vector search method, which performs a similarity search on a single vector field.
GET /book-index/_search
{
"knn": {
"field": "title_vector",
"query_vector": [0.1, 0.2, 0.3 ...],
"k": 10, // Number of top k results to return
"num_candidates": 100 // Number of candidate vectors to search on each shard
}
"fields": ["id", "title_text", "category"],
"_source": false,
}

Parameter description:
field: name of the vector field to search
query_vector: query vector. Its dimension must match the field definition.
k: number of the most similar documents to return
num_candidates: number of candidate vectors considered on each shard. A larger value improves accuracy but reduces performance.
You can also directly input the query text to generate the query vector through online inference (same below):
GET /book-index/_search
{
"knn": {
"field": "title_vector",
"query_vector_builder": {
"text_embedding": {
"model_id": "model-bge-base",
"model_text": "Sapiens: A Brief History of Humankind"
}
},
"k": 10, // Number of top k results to return
"num_candidates": 100 // Number of candidate vectors to search on each shard
},
"fields": ["id", "title_text", "category"],
"_source": false
}


Multi-Vector Search

ES supports searching multiple vector fields simultaneously and merging the results.
GET /book-index/_search
{
"query": {
"bool": {
"should": [
{
"knn": {
"field": "title_vector",
"query_vector": [0.1, 0.2, 0.3 ...],
"k": 5,
"num_candidates": 50,
"boost": 0.8
}
},
{
"knn": {
"field": "content_vector",
"query_vector": [0.1, 0.2, 0.3, ...],
"k": 5,
"num_candidates": 50,
"boost": 0.2
}
}
]
}
}
}
Features:
Two search methods are executed in parallel.
The results are merged and sorted by score.
You can use the boost parameter to adjust the weight of each field.
When the same document appears in different search results, the highest score is used.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백