dxmt-haystack
DXMT as a Haystack document store, with an embedding retriever, a BM25 retriever and a hybrid retriever.
pip install dxmt-haystack
A DXMT server has to be running (vectordb serve, or docker run -p 9999:9999 dxmtai/dxmt).
from haystack import Document, Pipeline
from haystack_integrations.document_stores.dxmt import DXMTDocumentStore
from haystack_integrations.components.retrievers.dxmt import (
DXMTBM25Retriever, DXMTEmbeddingRetriever, DXMTHybridRetriever,
)
store = DXMTDocumentStore(table_name="docs", embedding_dim=768, enable_full_text_search=True)
store.write_documents([
Document(content="rust borrows memory instead of collecting it", meta={"lang": "rust"}, embedding=[...]),
Document(content="go collects garbage instead of borrowing", meta={"lang": "go"}, embedding=[...]),
])
store.filter_documents({"field": "meta.lang", "operator": "==", "value": "rust"})
DXMTEmbeddingRetriever(store, top_k=5).run(query_embedding=[...])
DXMTBM25Retriever(store, top_k=5).run(query="garbage")
DXMTHybridRetriever(store, top_k=5).run(query="garbage", query_embedding=[...])
What the store does
- One document, one record.
idis the record id,embeddingthe vector,sparse_embeddingthe sparse vector, and the payload holdscontentandmetaas they are,metanested, so a filter onmeta.pageis the server pathmeta.page. - Documents without an embedding are kept, as in every Haystack store. The server wants a
vector per record, so such a document is written with a fixed stand-in vector and
__has_embedding: false; it comes back withembedding=Noneand the embedding retriever never ranks it. Withserver_embedding={"model": ...}the server embedscontentinstead and the embedding retriever takesquery_text. - Filters. The full Haystack filter language is supported by
filter_documents: a filter the server has a flat form for (==,!=, numeric ranges,in,not in,AND,OR,NOTof one condition) runs on the server; anything else (dates, strings under>,None, nestedANDinsideOR,NOTover several conditions) is evaluated with Haystack's owndocument_matches_filterover a scroll of the table, which is correct and slower. The retrievers only take filters with a server form and refuse the rest by name, because a ranked page cannot be filtered afterwards without changing what it means. - Duplicate policies
NONEandOVERWRITEupsert,SKIPwrites only the missing ids,FAILraisesDuplicateDocumentError. blobis not stored (DXMT payloads are JSON); a warning says so.
Tests
tests/test_document_store.py runs Haystack's own DocumentStoreBaseTests (count, write, delete
and 39 filter cases, with the in-memory evaluator as the oracle) against a live server:
DXMT_HOST=127.0.0.1 DXMT_PORT=9999 pytest
tests/test_filters.py needs no server and pins which filters get a server form.
Metadata
Release files for dxmt-haystack 1.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dxmt_haystack-1.6.0.tar.gz | 17.9 kB | Without provenance | Details for dxmt_haystack-1.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dxmt_haystack-1.6.0-py3-none-any.whl | Python 3 | none | any | Details for dxmt_haystack-1.6.0-py3-none-any.whl |
Total release size: 34.0 kB
Release files / dxmt_haystack-1.6.0.tar.gz
| Download URL | dxmt_haystack-1.6.0.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b441dabbae68da8050404f05c44a0decd8d50a12929077d6e7d5c85a69250c0
|
|
BLAKE2b-256 checksum How to use checksums |
acc62001b480b46797d7554ec55d20b9516b8c7df812720d17cd1ac864dae982
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Release files / dxmt_haystack-1.6.0-py3-none-any.whl
| Download URL | dxmt_haystack-1.6.0-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
402aede5d5395f5de0305becdd877a20c8c81ee47487567fb32570770e1437a9
|
|
BLAKE2b-256 checksum How to use checksums |
1af1d281875a59a5fbfd08d2ff8a077aaae9db6088d452dfbfb054fee8ce6e8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Security for dxmt-haystack 1.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.