Qx search: OpenSearch/Elasticsearch async client, repository abstraction, index lifecycle helpers (V2 stub)
Project description
qx-search
OpenSearch/Elasticsearch async client and repository abstraction for the Qx framework.
What lives here
qx.search.SearchRepository[TDoc]— abstract base class for document repositories. Implementindex_nameandto_document/from_documentmapping; the base providesindex,get,delete, andsearchmethods.qx.search.SearchQuery— composable query builder: full-text query, filters, sort, pagination offset, and highlight options.qx.search.SearchHit[TDoc]— single search result with the mapped document, score, and raw_source.qx.search.SearchSettings— Pydantic settings for the OpenSearch/Elasticsearch endpoint URL and optional auth.qx.search.create_search_client— async factory that opens anAsyncOpenSearchconnection.qx.search.ensure_index/drop_index— index lifecycle helpers;ensure_indexcreates an index with provided mapping if it doesn't exist (idempotent).
Usage
from qx.search import SearchRepository, SearchQuery, SearchSettings, create_search_client
class ProductSearchRepository(SearchRepository[ProductDoc]):
index_name = "products"
def to_document(self, product: Product) -> dict:
return {"id": str(product.id), "name": product.name, "sku": product.sku}
def from_document(self, doc: dict) -> ProductDoc:
return ProductDoc(**doc)
# Bootstrap
client = await create_search_client(settings.search)
repo = ProductSearchRepository(client)
# Index a document
await repo.index(product)
# Search
hits = await repo.search(SearchQuery(q="widget", filters={"category": "tools"}, size=20))
Design rules
SearchRepositoryintentionally does not extendqx.db.Repository— search is a read projection, not the system of record. Write to the DB first, sync to search via an integration event handler.ensure_indexis safe to call at startup on every deploy; it is a no-op if the index already exists with a compatible mapping.- This package is a V2 scope item. The
InMemorySearchRepositorytest double lives inqx-testing.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
qx_search-1.1.0.tar.gz
(8.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qx_search-1.1.0.tar.gz.
File metadata
- Download URL: qx_search-1.1.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb266dad4d92e92604480850622ee9efa92870937a0b654add2c6faf565c837a
|
|
| MD5 |
fa04620f890435aef5c444e7ea7c2c02
|
|
| BLAKE2b-256 |
017b9e7e0fa0e2a725045445459104b69f42f35d98e04e51951621967a4858e6
|
File details
Details for the file qx_search-1.1.0-py3-none-any.whl.
File metadata
- Download URL: qx_search-1.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
146443705a763ee26a8ef3fcfb3858bc31345c504982df6c3519488402216fb5
|
|
| MD5 |
094b6a574da6c15cb3b106e5709cff18
|
|
| BLAKE2b-256 |
d56782274ef978c87a900ddf6875abf579f07db310ce3085cd9cebf31097507f
|