--- title: "查询嵌入模型" date: 2026-01-14 lastmod: 2026-01-14 description: "说明 Easysearch 中查询嵌入模型相关 API 的情况。" tags: ["AI", "嵌入向量", "API说明"] summary: "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 在搜索时进行语义查询增强:" --- ## 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` 处理器在文档索引时自动生成嵌入向量: ```json 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` 在搜索时进行语义查询增强: ```json 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 配置 ```yaml # easysearch.yml ollama.url: "http://localhost:11434" ``` ### OpenAI 配置 ```yaml # 通过 API 密钥配置 ``` ## 支持的嵌入模型 | 模型名称 | 描述 | 类型 | |---------|------|------| | `nomic-embed-text:latest` | Nomic 文本嵌入模型 | Ollama | | `text-embedding-ada-002` | OpenAI 嵌入模型 | OpenAI | | `text-embedding-3-large` | OpenAI 大型嵌入模型 | OpenAI | ## 使用示例 ### 创建带嵌入的文档 ```json POST /my-index/_doc?pipeline=embedding-pipeline { "title": "Hello World", "content": "This is a sample document" } ``` ### 使用语义搜索 ```json GET /my-index/_search?search_pipeline=semantic-pipeline { "query": { "match": { "content": "sample text" } } } ``` ## 嵌入向量字段配置 索引中需要定义向量字段: ```json PUT /my-index { "mappings": { "properties": { "content": { "type": "text" }, "content_embedding": { "type": "dense_vector", "dims": 768, "index": true, "similarity": "cosine" } } } } ``` ## 注意事项 1. `GET /_ai/embeddings/{model}` API 在 Easysearch 中不存在 2. 相关的嵌入 REST API 已废弃 3. 建议使用摄入管道和搜索管道实现嵌入功能 4. 向量字段需要在索引映射中预先定义 ## 相关文档 - [创建或更新摄入管道](./create-or-update-ingest-pipeline.md) - [创建搜索管道](./create-search-pipeline.md) - [创建嵌入向量](./create-embedding-vector.md)