AS AgentScopeAPI 手册 / API Reference

ElasticsearchStore

public class ElasticsearchStore implements VDBStoreBase, AutoCloseable
源码Source io/agentscope/core/rag/store/ElasticsearchStore.java:88–590

Elasticsearch 存储,负责持久化与读取数据。位于 io.agentscope.core.rag.store 包,实现 VDBStoreBase、AutoCloseable。核心成员包括 add、search、delete、close、builder。

Elasticsearch vector database store implementation.

This class provides an interface for storing and searching vectors using Elasticsearch. It uses the official elasticsearch-java client.

The implementation uses the dense_vector field type for storing embeddings and kNN search for retrieval.

Example usage:

`// Using builder with authentication
try (ElasticsearchStore store = ElasticsearchStore.builder()
.url("http://localhost:9200")
.indexName("my_rag_index")
.dimensions(1024)
.username("elastic")
.password("changeme")
.build()) {

store.add(document).block();
List<Document> results = store.search(queryEmbedding, 5, 0.7).block();
}
`

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
ElasticsearchStore的构建器。
Builder for ElasticsearchStore.

方法摘要Method Summary

方法Method说明Description
public Mono<Void> add(List<Document> documents)
设置添加。
Adds a list of documents to the Elasticsearch index.
public Mono<List<Document>> search(SearchDocumentDto searchDocumentDto)
设置搜索。
Searches for documents in the Elasticsearch index matching the query embedding.
public Mono<Boolean> delete(String id)
删除数据。
Deletes a document from the Elasticsearch index by its ID.
public void close()
关闭连接并释放相关资源。
Releases resources and connections.
public static Builder builder()
static
创建新的构建器用于 ElasticsearchStore。
Creates a new builder for ElasticsearchStore.

方法详情Method Detail

add

public Mono<Void> add(List<Document> documents)

设置添加。

Adds a list of documents to the Elasticsearch index.

参数Parameters
名称Name类型Type说明Description
documentsList<Document>文档到添加的列出。the list of documents to add
返回Returns Mono<Void>
返回Mono。a Mono that completes when the operation is finished
源码Source io/agentscope/core/rag/store/ElasticsearchStore.java:180–198

delete

public Mono<Boolean> delete(String id)

删除数据。

Deletes a document from the Elasticsearch index by its ID.

参数Parameters
名称Name类型Type说明Description
idString文档到删除的标识。the ID of the document to delete
返回Returns Mono<Boolean>
返回Mono。a Mono containing true if the document was deleted, false if not found
源码Source io/agentscope/core/rag/store/ElasticsearchStore.java:286–303

close

public void close()

关闭连接并释放相关资源。

Releases resources and connections.

源码Source io/agentscope/core/rag/store/ElasticsearchStore.java:305–308

builder

public static Builder builder()
static

创建新的构建器用于 ElasticsearchStore。

Creates a new builder for ElasticsearchStore.

返回Returns Builder
一种新的构建器实例。a new Builder instance
源码Source io/agentscope/core/rag/store/ElasticsearchStore.java:494–496

嵌套类详情Nested Class Detail

Builder

public static class Builder

ElasticsearchStore的构建器。位于 io.agentscope.core.rag.store 包。核心成员包括 url、indexName、dimensions、username、password、disableSslVerification。

Builder for ElasticsearchStore.

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.