Skip to main content

lexigram-search

Full-text search and indexing for Lexigram Framework — Elasticsearch, Meilisearch, Typesense, and OpenSearch


Overview

lexigram-search provides a unified SearchEngineProtocol interface over Meilisearch, Elasticsearch, OpenSearch, Typesense, PostgreSQL full-text, MySQL, MongoDB, and SQLite. It supports typo-tolerant search, faceting, fuzzy matching, result caching, and analytics. All services are wired via SearchProvider, which registers the search engine protocol with the DI container.


Full documentation: docs.lexigram.dev

Install

uv add lexigram-search
# Optional extras
uv add "lexigram-search[meilisearch]"     # Meilisearch
uv add "lexigram-search[elasticsearch]"   # Elasticsearch 8.x
uv add "lexigram-search[typesense]"       # Typesense
uv add "lexigram-search[postgres,mysql,sqlite,mongodb]"  # Database backends

Quick Start

from lexigram import Application
from lexigram.di.module import Module, module

# Import the module from the package
from lexigram.search import SearchModule


@module(imports=[SearchModule.configure(...)])
class AppModule(Module):
    pass


async with Application.boot(modules=[AppModule]) as app:
    # use app.container to resolve services
    ...

Configuration

Default config: Pass SearchConfig() explicitly to use all defaults (in-memory backend). SearchModule.configure() with no arguments raises ValueError — a config or engine must be specified. The in-memory NullBackend is fine for development and tests.

Option 1 — YAML file

# application.yaml
search:
  backend_type: meilisearch
  meilisearch:
    url: http://localhost:7700
    api_key: "${MEILI_API_KEY}"
  query:
    strategy: fuzzy
    default_limit: 10

Option 2 — Profiles + Environment Variables (recommended)

export LEX_SEARCH__ENABLED=true
# Environment variables for each field

Option 3 — Python

from lexigram.search.config import SearchConfig, BackendType
from lexigram.search import SearchModule

config = SearchConfig(backend_type=BackendType.MEILISEARCH, ...)
SearchModule.configure(config)

Config reference

Field Default Env var Description
backend_type memory LEX_SEARCH__BACKEND_TYPE Active backend (meilisearch, elasticsearch, opensearch, typesense, postgres, mysql, sqlite, mongodb, memory)
timeout 30.0 LEX_SEARCH__TIMEOUT Default request timeout in seconds
query.strategy fuzzy LEX_SEARCH__QUERY__STRATEGY Query strategy (fuzzy, exact, semantic, hybrid)
query.default_limit 20 LEX_SEARCH__QUERY__DEFAULT_LIMIT Default number of results returned
query.max_limit 100 LEX_SEARCH__QUERY__MAX_LIMIT Maximum allowed result limit
query.fuzzy_threshold 0.8 LEX_SEARCH__QUERY__FUZZY_THRESHOLD Fuzzy match threshold (0–1; 1 = exact)
meilisearch.url http://localhost:7700 LEX_SEARCH__MEILISEARCH__URL MeiliSearch server URL
meilisearch.api_key null LEX_SEARCH__MEILISEARCH__API_KEY MeiliSearch authentication key
elasticsearch.hosts [http://localhost:9200] LEX_SEARCH__ELASTICSEARCH__HOSTS Elasticsearch cluster hosts
operations.bulk_chunk_size 500 LEX_SEARCH__OPERATIONS__BULK_CHUNK_SIZE Documents per bulk index request

Module Factory Methods

Method Description
SearchModule.configure(config, enable_facets) Configure with explicit SearchConfig
SearchModule.stub() Minimal config for testing

Key Features

  • Protocol abstraction — Swap backends without changing application code
  • Meilisearch — Typo-tolerant, instant search with faceting
  • Elasticsearch — Full Lucene query DSL; aggregations; multi-index
  • Typesense — Fast, schema-enforced search with scoped API keys
  • PostgreSQL FTStsvector/tsquery via lexigram-sql; no extra infra
  • MySQL FTSFULLTEXT index support for MySQL / MariaDB
  • MongoDB Text — Native $text operator with language stemming
  • SQLite FTS5 — Local development with zero dependencies
  • Cached search — Transparent result caching via CacheBackend
  • Analytics — Query recording and hit-rate analytics for ranking improvement

Testing

async with Application.boot(modules=[SearchModule.stub()]) as app:
    # your test code
    ...

Key Source Files

File What it contains
src/lexigram/search/module.py SearchModule class with factory methods
src/lexigram/search/di/provider.py SearchProvider — wires search protocols into DI container
src/lexigram/search/config.py SearchConfig and sub-config classes
src/lexigram/search/engine/ Search engine abstraction and federation
src/lexigram/search/backends/ Search engine implementations for each backend
src/lexigram/search/indexing/ Index management and document indexing

Download files

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

Source Distribution

lexigram_search-0.1.5001.tar.gz (183.3 kB view details)

Uploaded Source

Built Distribution

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

lexigram_search-0.1.5001-py3-none-any.whl (153.3 kB view details)

Uploaded Python 3

File details

Details for the file lexigram_search-0.1.5001.tar.gz.

File metadata

  • Download URL: lexigram_search-0.1.5001.tar.gz
  • Upload date:
  • Size: 183.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for lexigram_search-0.1.5001.tar.gz
Algorithm Hash digest
SHA256 082cb23b5f50801b16da7a0d75082153d9c4488798a2db7fe1b8eef31657be1d
MD5 ad14588c9e487895128ab7a0b9901d2b
BLAKE2b-256 178b032b311ce2c6ee6a41f5fdb8087ec37437d6d0eb02887d2e5dcca1fea49a

See more details on using hashes here.

File details

Details for the file lexigram_search-0.1.5001-py3-none-any.whl.

File metadata

File hashes

Hashes for lexigram_search-0.1.5001-py3-none-any.whl
Algorithm Hash digest
SHA256 50d28d3be66e3dbef20a926207c3dfa450d5ee3f711dc5449e38b66db137c8c3
MD5 f235cc3e22a3a09ddf768921757b7ff5
BLAKE2b-256 92117e26ba30bdfa9ecac1d0c01986ae29bde63e9f251b5622e3731126521681

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.5009

1 file

0.1.5005

2 files

This release

0.1.5001 This release

2 files

0.1.3007

1 file

0.1.3006

1 file

0.1.3005

1 file

0.1.4

2 files

0.1.2

1 file

0.1.0

2 files

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