API 状态说明 #
在 Easysearch 中,不存在 GET /_ai/embeddings/{model} API。
相关的 AI 嵌入功能 #
虽然不存在 GET /_ai/embeddings/{model} API,但 Easysearch 提供了其他嵌入相关功能:
已废弃的嵌入 API #
以下 API 已废弃(返回 410 Gone):
POST /_ai/embed
POST /_ai/embed/{model}
当前推荐的嵌入方式 #
Easysearch 推荐通过以下方式使用嵌入功能:
1. 摄取管道(Ingest Pipeline) #
使用 text_embedding 处理器在文档索引时自动生成嵌入向量:
PUT /_ingest/pipeline/embedding-pipeline
{
"processors": [
{
"text_embedding": {
"model": "nomic-embed-text:latest",
"text_field": "content",
"vector_field": "content_embedding"
}
}
]
}
2. 搜索管道(Search Pipeline) #
使用 semantic_query_enricher 在搜索时进行语义查询增强:
PUT /_search/pipeline/semantic-pipeline
{
"request_processors": [
{
"semantic_query_enricher": {
"model_name": "text-embedding-ada-002",
"text_field": "query_text",
"embedding_field": "content_embedding"
}
}
]
}
模型配置 #
Easysearch 通过配置文件或环境变量配置嵌入模型:
Ollama 配置 #
# easysearch.yml
ollama.url: "http://localhost:11434"
OpenAI 配置 #
# 通过 API 密钥配置
支持的嵌入模型 #
| 模型名称 | 描述 | 类型 |
|---|---|---|
nomic-embed-text:latest | Nomic 文本嵌入模型 | Ollama |
text-embedding-ada-002 | OpenAI 嵌入模型 | OpenAI |
text-embedding-3-large | OpenAI 大型嵌入模型 | OpenAI |
使用示例 #
创建带嵌入的文档 #
POST /my-index/_doc?pipeline=embedding-pipeline
{
"title": "Hello World",
"content": "This is a sample document"
}
使用语义搜索 #
GET /my-index/_search?search_pipeline=semantic-pipeline
{
"query": {
"match": {
"content": "sample text"
}
}
}
嵌入向量字段配置 #
索引中需要定义向量字段:
PUT /my-index
{
"mappings": {
"properties": {
"content": {
"type": "text"
},
"content_embedding": {
"type": "dense_vector",
"dims": 768,
"index": true,
"similarity": "cosine"
}
}
}
}
注意事项 #
GET /_ai/embeddings/{model}API 在 Easysearch 中不存在- 相关的嵌入 REST API 已废弃
- 建议使用摄入管道和搜索管道实现嵌入功能
- 向量字段需要在索引映射中预先定义





