Skip to content

Commit d814974

Browse files
committed
feat: Qdrant storage support
Signed-off-by: Anush008 <[email protected]>
1 parent 2015fc5 commit d814974

File tree

6 files changed

+305
-49
lines changed

6 files changed

+305
-49
lines changed

docs/docs/ops/storages.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ description: CocoIndex Built-in Storages
1111

1212
The spec takes the following fields:
1313

14-
* `database_url` (type: `str`, optional): The URL of the Postgres database to use as the internal storage, e.g. `postgres://cocoindex:cocoindex@localhost/cocoindex`. If unspecified, will use the same database as the [internal storage](/docs/core/basics#internal-storage).
14+
* `database_url` (type: `str`, optional): The URL of the Postgres database to use as the internal storage, e.g. `postgres://cocoindex:cocoindex@localhost/cocoindex`. If unspecified, will use the same database as the [internal storage](/docs/core/basics#internal-storage).
1515

16-
* `table_name` (type: `str`, optional): The name of the table to store to. If unspecified, will generate a new automatically. We recommend specifying a name explicitly if you want to directly query the table. It can be omitted if you want to use CocoIndex's query handlers to query the table.
16+
* `table_name` (type: `str`, optional): The name of the table to store to. If unspecified, will generate a new automatically. We recommend specifying a name explicitly if you want to directly query the table. It can be omitted if you want to use CocoIndex's query handlers to query the table.
17+
18+
## Qdrant
19+
20+
`Qdrant` exports data to a [Qdrant](https://qdrant.tech/) collection.
21+
22+
The spec takes the following fields:
23+
24+
* `qdrant_url` (type: `str`, required): The [gRPC URL](https://qdrant.tech/documentation/interfaces/#grpc-interface) of the Qdrant instance. Defaults to <http://localhost:6334/>.
25+
26+
* `collection` (type: `str`, required): The name of the collection to export the data to.

examples/pdf_embedding/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def pdf_embedding_flow(flow_builder: cocoindex.FlowBuilder, data_scope: cocoinde
6060

6161
doc_embeddings.export(
6262
"doc_embeddings",
63-
cocoindex.storages.Postgres(),
63+
cocoindex.storages.Qdrant(qdrant_url="http://localhost:6333", collection_name="cocoindex"),
6464
primary_key_fields=["filename", "location"],
6565
vector_index=[("embedding", cocoindex.VectorSimilarityMetric.COSINE_SIMILARITY)])
6666

python/cocoindex/storages.py

+5
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ class Postgres(op.StorageSpec):
66

77
database_url: str | None = None
88
table_name: str | None = None
9+
10+
class Qdrant(op.StorageSpec):
11+
"""Storage powered by Qdrant - https://qdrant.tech/."""
12+
13+
collection_name: str

src/ops/interface.rs

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ pub enum ExecutorFactory {
132132
ExportTarget(Arc<dyn ExportTargetFactory + Send + Sync>),
133133
}
134134

135+
#[derive(Debug)]
135136
pub struct VectorMatchQuery {
136137
pub vector_field_name: String,
137138
pub vector: Vec<f32>,

src/ops/registration.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ fn register_executor_factories(registry: &mut ExecutorFactoryRegistry) -> Result
1313
functions::extract_by_llm::Factory.register(registry)?;
1414

1515
Arc::new(storages::postgres::Factory::default()).register(registry)?;
16+
Arc::new(storages::qdrant::Factory::default()).register(registry)?;
1617

1718
Ok(())
1819
}

0 commit comments

Comments
 (0)