AS AgentScopeAPI 手册 / API Reference

QdrantStore

public class QdrantStore implements VDBStoreBase, AutoCloseable
源码Source io/agentscope/core/rag/store/QdrantStore.java:112–1096

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

Qdrant vector database store implementation.

This class provides an interface for storing and searching vectors using Qdrant, a production-ready vector database. It implements the VDBStoreBase interface to provide a unified API for vector storage operations.

In Qdrant, we use the payload field to store the metadata, including the document ID, chunk ID, and original content.

This implementation uses the Qdrant Java SDK (io.qdrant:client). To use this class, add the following dependency:

`<dependency>
<groupId>io.qdrant</groupId>
<artifactId>client</artifactId>
<version>1.15.0</version>
<scope>provided</scope>
</dependency>
`

Example usage:

`// Using builder with TLS and compatibility options (recommended)
try (QdrantStore store = QdrantStore.builder()
.location("http://localhost:6333")
.collectionName("my_collection")
.dimensions(1024)
.apiKey("my-api-key")
.useTransportLayerSecurity(true)
.checkCompatibility(false)
.build()) {
store.add(document).block();
List<Document> results = store.search(queryEmbedding, 5).block();
// Store is automatically closed here
}

// Using static factory method (simpler, uses defaults)
try (QdrantStore store = QdrantStore.create("http://localhost:6333", "my_collection", 1024)) {
store.add(document).block();
List<Document> results = store.search(queryEmbedding, 5).block();
}
`

Note: The location parameter can be:

  • HTTP URL: "http://localhost:6333" - will use gRPC on port 6334

  • gRPC URL: "localhost:6334" - direct gRPC connection

  • Local path: "file:///path/to/qdrant" - local Qdrant instance

  • Memory mode: ":memory:" - in-memory Qdrant (requires local Qdrant)

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
构建器,用于构建并配置目标实例。
Builder for creating QdrantStore instances with fluent configuration.

方法摘要Method Summary

方法Method说明Description
public Mono<Void> add(List<Document> documents)
设置添加。
Performs the add operation.
public Mono<List<Document>> search(SearchDocumentDto searchDocumentDto)
设置搜索。
Performs the search operation.
public Mono<Boolean> delete(String id)
删除数据。
Performs the delete operation.
public QdrantClient getClient() throws VectorStoreException
获取客户端。
Gets the underlying Qdrant client for advanced operations.
public QdrantGrpcClient getGrpcClient() throws VectorStoreException
获取gRPC 客户端。
Gets the underlying gRPC client for low-level operations.
public String getLocation()
获取 `getLocation`。
Gets the Qdrant server location.
public String getCollectionName()
获取集合名称。
Gets the collection name.
public int getDimensions()
获取向量维度。
Gets the vector dimensions.
public String getApiKey()
获取API 密钥(if 设置)。
Gets the API key (if set).
public void close()
关闭连接并释放相关资源。
Closes the Qdrant client and releases all resources.
public boolean isClosed()
判断是否已关闭。
Checks if this store has been closed.
public static Builder builder()
static
返回构建器实例。
Creates a new builder for constructing QdrantStore instances.

方法详情Method Detail

add

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

设置添加。

Performs the add operation.

参数Parameters
名称Name类型Type说明Description
documentsList<Document>文档列表(类型 `List`)。The documents.
返回Returns Mono<Void>
返回Mono。Returns mono.
源码Source io/agentscope/core/rag/store/QdrantStore.java:202–247

delete

public Mono<Boolean> delete(String id)

删除数据。

Performs the delete operation.

参数Parameters
名称Name类型Type说明Description
idString标识(类型 `String`)。The id.
返回Returns Mono<Boolean>
返回Mono。Returns mono.
源码Source io/agentscope/core/rag/store/QdrantStore.java:290–313

getClient

public QdrantClient getClient() throws VectorStoreException

获取客户端。

Gets the underlying Qdrant client for advanced operations.

返回Returns QdrantClient
QdrantClient 实例。the QdrantClient instance
抛出Throws
  • VectorStoreException 可能抛出 `VectorStoreException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/core/rag/store/QdrantStore.java:330–333

getGrpcClient

public QdrantGrpcClient getGrpcClient() throws VectorStoreException

获取gRPC 客户端。

Gets the underlying gRPC client for low-level operations.

返回Returns QdrantGrpcClient
QdrantGrpcClient 实例。the QdrantGrpcClient instance
抛出Throws
  • VectorStoreException 可能抛出 `VectorStoreException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/core/rag/store/QdrantStore.java:344–347

getLocation

public String getLocation()

获取 getLocation。

Gets the Qdrant server location.

返回Returns String
返回字符串结果。the location
源码Source io/agentscope/core/rag/store/QdrantStore.java:873–875

getCollectionName

public String getCollectionName()

获取集合名称。

Gets the collection name.

返回Returns String
集合名称。the collection name
源码Source io/agentscope/core/rag/store/QdrantStore.java:882–884

getDimensions

public int getDimensions()

获取向量维度。

Gets the vector dimensions.

返回Returns int
维度。the dimensions
源码Source io/agentscope/core/rag/store/QdrantStore.java:891–893

getApiKey

public String getApiKey()

获取API 密钥(if 设置)。

Gets the API key (if set).

返回Returns String
返回字符串结果。the API key, or null if not set
源码Source io/agentscope/core/rag/store/QdrantStore.java:900–902

close

public void close()

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

Closes the Qdrant client and releases all resources.

源码Source io/agentscope/core/rag/store/QdrantStore.java:921–954

isClosed

public boolean isClosed()

判断是否已关闭。

Checks if this store has been closed.

返回Returns boolean
返回布尔值,表示判断结果。true if the store has been closed, false otherwise
源码Source io/agentscope/core/rag/store/QdrantStore.java:961–963

builder

public static Builder builder()
static

返回构建器实例。

Creates a new builder for constructing QdrantStore instances.

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

嵌套类详情Nested Class Detail

Builder

public static class Builder

构建器,用于构建并配置目标实例。位于 io.agentscope.core.rag.store 包。核心成员包括 location、collectionName、dimensions、apiKey、useTransportLayerSecurity、checkCompatibility。

Builder for creating QdrantStore instances with fluent configuration.

Example usage:

`QdrantStore store = QdrantStore.builder()
.location("http://localhost:6333")
.collectionName("my_collection")
.dimensions(1024)
.apiKey("my-api-key")
.useTransportLayerSecurity(true)
.checkCompatibility(false)
.build();
`
基于官方固定版本源码静态生成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.