Skip to main content

Modern Python client for Apache Solr built with httpx and Pydantic.

Project description

Taiyo

Taiyo is a Python client for Apache Solr built with httpx and Pydantic.

The library provides a type-safe interface for interacting with Apache Solr, supporting both synchronous and asynchronous operations. It includes comprehensive support for Solr's query parsers, schema management, and vector search capabilities.

Features

  • Synchronous and asynchronous client implementations with httpx
  • Type safety with Pydantic for runtime validation and IDE support
  • Support for Solr query parsers for sparse (standard, dismax, edismax), dense vector and spatial search
  • Pythonic method chains for grouping/faceting/highlighting search results
  • Programmatic schema definition for indexing
  • Authentication via Basic Auth, Bearer Token, and OAuth2

Installation

pip install taiyo

Or using uv:

uv add taiyo

Quick Start

from typing import Optional
from taiyo import SolrClient, SolrDocument
from taiyo.parsers import StandardQueryParser

class Passenger(SolrDocument):
    name: str
    sex: str
    age: Optional[float] = None
    survived: int
    pclass: int
    fare: Optional[float] = None
    embarked: Optional[str] = None

with SolrClient("http://localhost:8983/solr") as client:
    client.set_collection("titanic")
    
    passenger = Passenger(
        name="Braund, Mr. Owen Harris",
        sex="male",
        age=22.0,
        survived=0,
        pclass=3,
        fare=7.25,
        embarked="S"
    )
    client.add(passenger, commit=True)
    
    parser = StandardQueryParser(
        query="sex:male AND pclass:3",
        filter_queries=["age:[20 TO 30]"]
    )
    results: list[Passenger] = client.search(parser, rows=10, document_model=Passenger)
    
    print(f"Found {results.num_found} passengers")
    for doc in results.documents:
        print(f"{passenger.name}, Age: {passenger.age}, Class: {passenger.pclass}")

Async Support

from typing import Optional
from taiyo import AsyncSolrClient, SolrDocument
from taiyo.parsers import StandardQueryParser

class Passenger(SolrDocument):
    name: str
    sex: str
    age: Optional[float] = None
    survived: int
    pclass: int
    fare: Optional[float] = None

async with AsyncSolrClient("http://localhost:8983/solr") as client:
    client.set_collection("titanic")
    
    # Batch indexing
    passengers = [
        Passenger(name="Allen, Miss. Elisabeth", sex="female", age=29.0, survived=1, pclass=1, fare=211.34),
        Passenger(name="Moran, Mr. James", sex="male", age=None, survived=0, pclass=3, fare=8.46)
    ]
    await client.add(passengers, commit=True)
    
    # Search with filtering
    parser = StandardQueryParser(
        query="pclass:1 AND survived:1",
        filter_queries=["sex:female"]
    )
    results = await client.search(parser)
    
    # Type-safe result processing
    for doc in results.documents:
        p = Passenger.model_validate(doc)
        print(f"{p.name} survived, paid ${p.fare}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

taiyo-0.1.0.tar.gz (54.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

taiyo-0.1.0-py3-none-any.whl (71.8 kB view details)

Uploaded Python 3

File details

Details for the file taiyo-0.1.0.tar.gz.

File metadata

  • Download URL: taiyo-0.1.0.tar.gz
  • Upload date:
  • Size: 54.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for taiyo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 780592f90280d68026b49bfa6aa6ee3a7c755f0dc910c0108dcc362cd1a27620
MD5 dcb67f792bbb45bc0860a25970e5dbfd
BLAKE2b-256 1c47a011e4119db79d0be6658e911811b81699ac9c760ac1e40f46528667b655

See more details on using hashes here.

File details

Details for the file taiyo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: taiyo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 71.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for taiyo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efa5896261aaa24a77ad9b0ed4538bab17a2dfdf4c760f69a761dfceda381820
MD5 cdfcaa90ab58352ae3b74f2dd3d490ca
BLAKE2b-256 3969965f4c7d65cff74273f961106a025251ad42ed65d0c19f5452b683ee7fe1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page