Skip to main content

Toshi Python Client

This repository is a client for the Full-Text Search Engine Toshi. It allows you to use all features implemented in the Toshi engine.

How to install

The client is available as a package on Pypi and can be installed via:

pip install toshi_client

Examples

For a full set of examples check out the integration tests.

Here is a basic example:

  1. Create an index and submit it
from toshi_client.client import ToshiClient
from toshi_client.index.index_builder import IndexBuilder
from toshi_client.index.field_options import TextOptionIndexing

builder = IndexBuilder()

builder.add_text_field(name="lyrics", stored=True, indexing=TextOptionIndexing())
builder.add_i64_field(name="year", stored=True, indexed=True)
builder.add_u64_field(name="idx", stored=True, indexed=True)
builder.add_text_field(name="artist", stored=True, indexing=TextOptionIndexing())
builder.add_text_field(name="genre", stored=True, indexing=TextOptionIndexing())
builder.add_text_field(name="song", stored=True, indexing=TextOptionIndexing())
builder.add_facet_field(name="test_facet", stored=True)

index = builder.build("lyrics")
    
client = ToshiClient("http://localhost:8080")
client.create_index(index=index)
  1. Create a document class according to the just created index
from toshi_client.models.document import Document

class Lyrics(Document):
    @staticmethod
    def index_name() -> str:
        return "lyrics"

    def __init__(
        self,
        lyrics: str,
        year: int,
        idx: int,
        artist: str,
        genre: str,
        song: str,
    ):
        self.lyrics = lyrics
        self.year = year
        self.idx = idx
        self.artist = artist
        self.genre = genre
        self.song = song
  1. Submit a document to Toshi
doc = Lyrics(
    lyrics="Gold on the ceiling, I ain't blind, just a matter of time",
    year=2011,
    idx=2,
    artist="The Black Keys",
    genre="Rock",
    song="Gold on the Ceiling",
    test_facet="/a/b",
)
client.add_document(document=doc)
  1. Use a query of your choice to retrieve it
from toshi_client.query.term_query import TermQuery

query = TermQuery(term="ceiling", field_name="lyrics")
documents = client.search(query, Lyrics)

Metadata

Release files for toshi-client 0.0.1

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

Source distribution (sdist)

Source distribution for toshi-client 0.0.1
File Size Uploaded Provenance
toshi_client-0.0.1.tar.gz 36.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for toshi-client 0.0.1
File Interpreter ABI Platform
toshi_client-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 49.6 kB

Release files / toshi_client-0.0.1.tar.gz

Download URL toshi_client-0.0.1.tar.gz
Size 36.1 kB
Tags Source
SHA-256 checksum
How to use checksums
72f3c2c5f0cf6ff186583e93c98fa4c694871d050d6c336c002b73bad01a497a
BLAKE2b-256 checksum
How to use checksums
db4efc41addc4acb5e816bbc156cdcbb83e79f4367617e42f0a2dc91a4e62455
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.0

Release files / toshi_client-0.0.1-py3-none-any.whl

Download URL toshi_client-0.0.1-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1cba6c4e24bdf82d331688a0146fcc6099936226c801a8bb609967e2d8ce765
BLAKE2b-256 checksum
How to use checksums
c9a19f8a9714b1c28f561883ba027b8ea37e5dfecda79cc74538183db35b5460
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.0

Security for toshi-client 0.0.1

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.0.1 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