Skip to main content

citadeldb-haystack

A Haystack DocumentStore backed by Citadel. Encrypted at rest, embedded in your process, and deletes that destroy the key, not just the row.

Passes deepset's own DocumentStoreBaseTests conformance suite.

pip install citadeldb-haystack
from haystack import Document
from haystack.utils import Secret
from citadeldb_haystack import CitadelDocumentStore

store = CitadelDocumentStore("corpus.cdl", Secret.from_env_var("CITADEL_KEY"))
# CITADEL_KEY must be set: an env-var secret is what lets a pipeline serialize.

store.write_documents([Document(id="d1", content="...", meta={"chapter": "intro"})])
store.filter_documents({"field": "meta.chapter", "operator": "==", "value": "intro"})

dim defaults to 768 and must match your embedding model.

The passphrase never lands in a pipeline file

The passphrase is a Haystack Secret. Pipelines are serialized to disk, and a literal token refuses to serialize, so a passphrase cannot be written into a pipeline by accident:

CitadelDocumentStore("literal.cdl", "literal-passphrase").to_dict()
# ValueError: Cannot serialize token-based secret.

CitadelDocumentStore("corpus.cdl", Secret.from_env_var("CITADEL_KEY")).to_dict()
# {... "key": {"type": "env_var", "env_vars": ["CITADEL_KEY"], ...}}

Use Secret.from_env_var for any store that goes into a saved pipeline.

Deletes destroy the key

Every document is sealed under its own key. Deleting destroys that key and then removes the row, so any ciphertext surviving elsewhere stays unreadable.

store.delete_documents(["d1"])
store.delete_all()             # returns the number erased

DuplicatePolicy.NONE falls back to FAIL, as InMemoryDocumentStore does, so an accidental re-write is reported rather than silently replacing a document whose key would then be destroyed.

Retrieval

query_embedding = [0.0] * 768        # from your Haystack text embedder, `dim` wide

store.embedding_retrieval(query_embedding, top_k=5,
                          filters={"field": "meta.chapter", "operator": "==", "value": "intro"})

Filtering uses Haystack's own evaluator, so the whole filter language, date comparisons included, matches InMemoryDocumentStore operator for operator. top_k is top_k: a filter matching only distant documents still returns them, however many others outrank them.

A top-level AND of string equality conditions is pushed into the scan, including nested paths like meta.person.name. Everything else is evaluated afterwards, so the two agree: nothing is pushed under OR or NOT, and numbers are not pushed either, because == here is Python's (1 == 1.0) where the stored comparison is JSON-type exact.

Notes

Documents Haystack did not embed are stored, filterable and countable, but take no part in embedding_retrieval, as in InMemoryDocumentStore, which retrieves only documents that have embeddings.

Citadel is embedded and one process owns the file. A path already open on this thread, under the same passphrase, is shared, so this can sit on the same database as another Citadel adapter; construct them on the same thread.

License

Apache-2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

citadeldb_haystack-2.0.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

citadeldb_haystack-2.0.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file citadeldb_haystack-2.0.0.tar.gz.

File metadata

  • Download URL: citadeldb_haystack-2.0.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for citadeldb_haystack-2.0.0.tar.gz
Algorithm Hash digest
SHA256 0fa4ede7cf7099487ccd0f7221794bac87edddb823a15f6f616879581afeb815
MD5 f8783d56af48fd927803b523e75a73ed
BLAKE2b-256 ccf6b45ad4e0eea443d9773019c18dea095a251b726f0a38eb398c2257bf8772

See more details on using hashes here.

Provenance

The following attestation bundles were made for citadeldb_haystack-2.0.0.tar.gz:

Publisher: release-haystack.yml on yp3y5akh0v/citadel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file citadeldb_haystack-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for citadeldb_haystack-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dec1e502e688507648b8f3bff029c624c29dfeb907d4589cf8862977f202f28f
MD5 adebcff3752f391c5d8916d57db4d04f
BLAKE2b-256 6c74e1b482a612fb6c1682839229a6b08a1e6540a34a17284ad97838eda623d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for citadeldb_haystack-2.0.0-py3-none-any.whl:

Publisher: release-haystack.yml on yp3y5akh0v/citadel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page