Skip to content

feat: Qdrant storage support #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2015fc5
feat: Qdrant storage
Anush008 Mar 20, 2025
d814974
feat: Qdrant storage support
Anush008 Mar 24, 2025
8733bc1
Merge branch 'main' into qdrant
Anush008 Mar 24, 2025
b0e4a4d
chore: review updates
Anush008 Mar 26, 2025
61aa6d0
Merge branch 'main' into qdrant
Anush008 Mar 26, 2025
678f9fd
chore: New API check_state_compatibility
Anush008 Mar 26, 2025
f857b83
refactor: Simplify payload conversion
Anush008 Mar 27, 2025
3a4791a
Merge remote-tracking branch 'upstream/main' into qdrant
Anush008 Apr 8, 2025
4a0bdf5
refactor: No ResourceSetupStatusCheck
Anush008 Apr 8, 2025
a4c6cae
refactor: Replaced SetupState with ()
Anush008 Apr 8, 2025
67f1e71
feat: Parse point ID
Anush008 Apr 8, 2025
c5f6a9d
Merge remote-tracking branch 'upstream/HEAD' into qdrant
Anush008 Apr 12, 2025
d7f419b
chore: Support all Value::Basic values
Anush008 Apr 13, 2025
8125f53
Merge remote-tracking branch 'upstream/HEAD' into qdrant
Anush008 Apr 13, 2025
379797c
chore: Handle all BasicValue types in search(), doc updates
Anush008 Apr 13, 2025
a2b58b1
doc: End-to-end example
Anush008 Apr 13, 2025
9dc9abc
feat: Support for api_key
Anush008 Apr 13, 2025
aa2acda
fix: no process-level CryptoProvider available -- call CryptoProvider…
Anush008 Apr 13, 2025
20221ae
Merge branch 'main' into qdrant
Anush008 Apr 14, 2025
67e3608
chore: Removed key_value_fields_iter()
Anush008 Apr 14, 2025
86fc14c
docs: examples/text_embedding_qdrant
Anush008 Apr 14, 2025
f749375
chore: Undo change to examples/pdf_embedding
Anush008 Apr 14, 2025
d9c93d4
feat: Optionally delete points
Anush008 Apr 14, 2025
32d94f7
chore: parse BasicValueType::Date
Anush008 Apr 14, 2025
19dee3e
refactor: Don't nest complex types
Anush008 Apr 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ rustls = { version = "0.23.25" }
http-body-util = "0.1.3"
yaml-rust2 = "0.10.0"
urlencoding = "2.1.3"
qdrant-client = "1.13.0"
uuid = { version = "1.16.0", features = ["serde", "v4", "v8"] }
10 changes: 10 additions & 0 deletions docs/docs/ops/storages.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ The spec takes the following fields:
* `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).

* `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.

## Qdrant

`Qdrant` exports data to a [Qdrant](https://qdrant.tech/) collection.

The spec takes the following fields:

* `qdrant_url` (type: `str`, required): The [gRPC URL](https://qdrant.tech/documentation/interfaces/#grpc-interface) of the Qdrant instance. Defaults to http://localhost:6334/.

* `collection` (type: `str`, required): The name of the collection to export the data to.
2 changes: 1 addition & 1 deletion examples/pdf_embedding/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def pdf_embedding_flow(flow_builder: cocoindex.FlowBuilder, data_scope: cocoinde

doc_embeddings.export(
"doc_embeddings",
cocoindex.storages.Postgres(),
cocoindex.storages.Qdrant(collection_name="cocoindex"),
primary_key_fields=["id"],
vector_index=[("embedding", cocoindex.VectorSimilarityMetric.COSINE_SIMILARITY)])

Expand Down
5 changes: 5 additions & 0 deletions python/cocoindex/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ class Postgres(op.StorageSpec):

database_url: str | None = None
table_name: str | None = None

class Qdrant(op.StorageSpec):
"""Storage powered by Qdrant - https://qdrant.tech/."""

collection_name: str
1 change: 1 addition & 0 deletions src/ops/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ pub enum ExecutorFactory {
ExportTarget(Arc<dyn ExportTargetFactory + Send + Sync>),
}

#[derive(Debug)]
pub struct VectorMatchQuery {
pub vector_field_name: String,
pub vector: Vec<f32>,
Expand Down
1 change: 1 addition & 0 deletions src/ops/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fn register_executor_factories(registry: &mut ExecutorFactoryRegistry) -> Result
functions::extract_by_llm::Factory.register(registry)?;

Arc::new(storages::postgres::Factory::default()).register(registry)?;
Arc::new(storages::qdrant::Factory::default()).register(registry)?;

Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions src/ops/storages/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod postgres;
pub mod qdrant;
Loading