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.0.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.0.0.tar.gz.
File metadata
- Download URL: qx_search-1.0.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 |
0d67b80ac1bbd4c97423566be3acc568314fdf8aca692c8918fd7c0b12d9b7b9
|
|
| MD5 |
8c663e6b655b90f7b378c05d6d78f59c
|
|
| BLAKE2b-256 |
5fff898604390d9bf21923396e96d4d2d6e89aae81906c53d6cc198d85cfdf16
|
File details
Details for the file qx_search-1.0.0-py3-none-any.whl.
File metadata
- Download URL: qx_search-1.0.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 |
41ad2924957378b7acbb22b4297a735c3383b9a72afa999c64742c2e02026f86
|
|
| MD5 |
3408f1b80c76cf54541caa44ee0b0008
|
|
| BLAKE2b-256 |
3ac87a453985395884efa83518823cfca620de82bbfa9c09a694d439500a94a8
|