Skip to main content

Tests Codecov pypi versions

aio_typesense

Async Library for Typesense with type hints

pip install aio_typesense

Usage

# examples/example.py

import asyncio
from typing import TypedDict, List

from aio_typesense import Client, Collection


class Movie(TypedDict):
    id: str
    name: str
    year: int


MOVIES: List[Movie] = [
    {"id": "id1", "name": "Wonder Woman", "year": 2017, "year_facet": "2017"},
    {"id": "id2", "name": "Justice League", "year": 2017, "year_facet": "2017"},
    {"id": "id3", "name": "Wonder Woman 1984", "year": 2020, "year_facet": "2020"},
    {"id": "id4", "name": "Death on the Nile", "year": 2021, "year_facet": "2021"},
]


async def main():
    client = Client(
        node_urls=["http://localhost:8108"],
        api_key="Rhsdhas2asasdasj2",
    )

    r = await client.collections.create(
        {
            "name": "movies",
            "num_documents": 0,
            "fields": [
                {
                    "name": "name",
                    "type": "string",
                },
                {
                    "name": "year",
                    "type": "int32",
                },
                {
                    "name": "year_facet",
                    "type": "string",
                    "facet": True,
                },
            ],
            "default_sorting_field": "year",
        }
    )

    collection: Collection[Movie] = client.collections["movies"]

    r = await collection.documents.create_many(documents=MOVIES)
    print(r)

    search_r = await collection.documents.search(
        {
            "q": "wonder woman 2021",
            "query_by": "year_facet,name",
            "query_by_weights": "1,1",
        }
    )

    print(search_r["hits"])

    # [
    #     {
    #         "document": {
    #             "id": "id3",
    #             "name": "Wonder Woman 1984",
    #             "year": 2020,
    #             "year_facet": "2020",
    #         },
    #         "highlights": [
    #             {
    #                 "field": "year_facet",
    #                 "matched_tokens": ["2020"],
    #                 "snippet": "<mark>2020</mark>",
    #             }
    #         ],
    #         "text_match": 1125899907169635,
    #     },
    #     {
    #         "document": {
    #             "id": "id1",
    #             "name": "Wonder Woman",
    #             "year": 2017,
    #             "year_facet": "2017",
    #         },
    #         "highlights": [
    #             {
    #                 "field": "year_facet",
    #                 "matched_tokens": ["2017"],
    #                 "snippet": "<mark>2017</mark>",
    #             }
    #         ],
    #         "text_match": 1125899907169379,
    #     },
    #     {
    #         "document": {
    #             "id": "id4",
    #             "name": "Death on the Nile",
    #             "year": 2021,
    #             "year_facet": "2021",
    #         },
    #         "highlights": [
    #             {
    #                 "field": "year_facet",
    #                 "matched_tokens": ["2021"],
    #                 "snippet": "<mark>2021</mark>",
    #             }
    #         ],
    #         "text_match": 562949953552128,
    #     },
    #     {
    #         "document": {
    #             "id": "id2",
    #             "name": "Justice League",
    #             "year": 2017,
    #             "year_facet": "2017",
    #         },
    #         "highlights": [
    #             {
    #                 "field": "year_facet",
    #                 "matched_tokens": ["2017"],
    #                 "snippet": "<mark>2017</mark>",
    #             }
    #         ],
    #         "text_match": 562949953551616,
    #     },
    # ]


if __name__ == "__main__":
    asyncio.run(main())

Contributing

Prerequisites:

  • poetry
  • nox
  • nox-poetry

Install them on your system:

pip install poetry nox nox-poetry

Run tests:

nox

Metadata

Release files for aio-typesense 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aio-typesense 0.1.0
File Size Uploaded Provenance Actions
aio_typesense-0.1.0.tar.gz 6.4 kB Without provenance Details for aio_typesense-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aio-typesense 0.1.0
File Interpreter ABI Platform Actions
aio_typesense-0.1.0-py3-none-any.whl Python 3 none any Details for aio_typesense-0.1.0-py3-none-any.whl

Total release size: 14.2 kB

Release files / aio_typesense-0.1.0.tar.gz

Download URL aio_typesense-0.1.0.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
dbe0e45e44cc82b70b820cb5d8bc5b169350694a63934ef3f5064b72cd0690f9
BLAKE2b-256 checksum
How to use checksums
3371ee40f5aee2dcbff3f4e9d31c1abc73406610b80af382718a280e8f7135e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.9.1 Linux/5.4.87-1-lts

Release files / aio_typesense-0.1.0-py3-none-any.whl

Download URL aio_typesense-0.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea5c676fe641040a19dd2c4f616183bb2712cd3e1e6ba664436707c17c8021f9
BLAKE2b-256 checksum
How to use checksums
bc9e52c9eca34e6fd51966aba1eb139f7a0017c0ca936d54b566614a948628fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.9.1 Linux/5.4.87-1-lts

Security for aio-typesense 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page