tencent cloud

Elasticsearch Service

DokumentasiElasticsearch ServiceVector Search GuideSpecial Note on Simplifying Writes and Searches with the Semantic Field

Special Note on Simplifying Writes and Searches with the Semantic Field

Download
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-08-12 18:13:52
Diterjemahkan oleh AI
This document introduces the key points of semantic search. You can refer to the related document for more details.
The semantic field uses natural language directly for writes and queries, providing a simpler experience compared to k-nearest neighbor (kNN) queries. You only need to specify an inference service created based on a machine learning node or an inference endpoint to easily complete reads and writes, without creating an ingest pipeline or worrying about underlying model and inference details (such as dimensions, m, and ef).

Creating an Inference Endpoint

Create the model service deployed on a machine learning node as an inference endpoint (see here for more details on creating inference endpoints).
PUT _inference/text_embedding/bge-base-zh-service
{
"service": "elasticsearch",
"service_settings": {
"model_id": "bge-base-zh",
"num_allocations": 1,
"num_threads": 1
}
}

Creating an Index

The semantic field uses the built-in .elser-2-elastic inference endpoint (EIS service) from Elastic by default, which is a sparse vector embedding model. You can explicitly specify your own created inference endpoint:
PUT semantic_search_index
{
"mappings":{
"properties": {
"content_vector":{
"type":"semantic_text",
"inference_id":"bge-base-zh-service", // Specify the inference endpoint for writes and queries.
},
"content":{
"type":"text",
"copy_to":"content_vector"
}
}
}
}

Writing Data

During writes, the model is automatically called to generate vector data:
PUT semantic_search_index/_doc/1
{
"content":"Using semantic search simplifies data ingestion statements."
}

PUT semantic_search_index/_doc/2
{
"content":"Using semantic search simplifies data query statements."
}


Performing Semantic Search

Perform a match search with the query in natural language, as shown in the example below:
GET semantic_search_index/_search
{
"query": {
"match": {
"content_vector": {
"query": "What is semantic search ?"
}
}
}
}

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan