Skip to main content

Yeny Logo

Sponsor PyPI Python

🌐 Language / Idioma:   English  |  Español

A lightweight toolkit for building custom search systems in Python.

"An easy way to build search engines in Python."

Yeny is a lightweight, production-oriented search toolkit that helps you build full-text search features quickly, while still giving you advanced controls when your dataset grows.

It follows a progressive-power philosophy:

  • Start with pure Python and zero mandatory external dependencies.
  • Scale to SQL-backed persistence and temporal sharding when needed.
  • Keep API ergonomics simple through a single high-level Yeny entrypoint.

Table of Contents

Features

  • Pure Python engines (core and lite)
  • Built-in NLP preprocessors and tokenizers
  • Ranked retrieval with structured response models
  • Binary persistence (.yny) — memory-mapped index files for near-zero RAM loading, plus lightweight SQLite metadata (WAL mode). Persistence is automatic — from_dict(), from_list(), and from_table() all save without calling .save().
  • Direct DB ingestion — read from SQLite, MySQL, or PostgreSQL tables without polluting your database (read-only adapters, zero yeny_* tables on your DB)
  • Versioned index persistence with rollback support
  • Temporal sharding for large time-series corpora
  • Background reindexing with IndexWorker (zero-downtime)
  • Health and diagnostics reporting
  • Standalone utility functions for indexing and vector math
  • Optional JSON or full-SQL storage backends for simpler use cases

Installation

Install from PyPI:

pip install yeny

Optional SQL support:

# Generic SQLAlchemy support
pip install yeny[alchemy]

# MySQL
pip install yeny[mysql]

# PostgreSQL
pip install yeny[postgresql]

Alternatively, install from source:

git clone https://github.com/Ariiies/yeny.git
cd yeny
pip install .

Quick Start

from yeny import Yeny

documents = {
    "doc1": "Python is a versatile language for backend systems",
    "doc2": "JavaScript dominates modern frontend development",
    "doc3": "Yeny makes search implementation straightforward",
}

searcher = Yeny.from_dict(documents, name="demo_index", engine="core")
response = searcher.search("python frontend", top_k=2)

print(response)
# Output:
# SearchResponse(
#     query='python frontend',
#     tokens=['python', 'frontend'],
#     engine='CoreEngine',
#     total_results=2,
#     search_time_ms=0.14,
#     results=[
#         SearchResult(doc_id='doc1', score=0.2757, rank=1),
#         SearchResult(doc_id='doc2', score=0.2414, rank=2)
#     ]
# )

Factories persist automatically by default, generating the yeny_data/yny/ directory with .yny binaries and SQLite metadata (yeny_meta.db). Reload later with the same logical name:

loaded = Yeny(name="demo_index")
response = loaded.search("python")

For unit tests, quick prototyping, or zero-disk ephemeral environments, run 100% in-memory:

searcher = Yeny.from_list(["hello world"], persist=False)  # or options=YenyOptions(storage_type=None)
response = searcher.search("hello")

Advanced infrastructure stays optional and typed:

from yeny import Yeny
from yeny.config import YenyOptions, TableConfig, TableSource

options = YenyOptions(storage_dir="search_data", memory_limit_mb=512)
searcher = Yeny.from_table(
    TableSource(
        table="articles",
        connection_url=DB_URL,
        text_columns=["title", "body"],
        id_column="id",
        date_column="created_at",
    ),
    engine="lite",
    config=TableConfig(where_clause="published = 1"),
    options=options,
)

YenyOptions.binary_dir accepts "auto" (derive <storage_dir>/yny), None (disable .yny persistence), or an explicit directory.

Examples

Runnable, documented end-to-end scenarios live in examples/:

  • Encrypted search over MySQL — full-text search over Fernet-encrypted columns (name/email/number) using a blind index of HMAC-trigrams, temporal sharding, .yny persistence and an interactive playground. The whole Yeny integration fits in ~15 lines inside playground.py.
cd examples/encrypted_search
pip install "../..[encrypted-search-example]"
python seed_controlled_data.py && python playground.py

See examples/encrypted_search/README.md for setup, security model and adaptation guide.

Architecture Snapshot

                  ┌──────────────────┐
                  │  DatabaseReader  │  ← read-only (your DB)
                  │ SQLite / MySQL / │
                  │   PostgreSQL     │
                  └────────┬─────────┘
                           │ data ingestion
                           ▼
Documents → Preprocessors → Engine → Storage
                │                │
                ▼                ▼
          Tokenizers      ┌──────────────┐
          (word, char,    │ .yny binaries │  ← mmap (index data)
           n-gram)        │  + SQLite WAL │  ← metadata & aliases
                          └──────────────┘
  • yeny.main.Yeny: high-level API and orchestration (Facade pattern)
  • yeny.engines:
    • CoreEngine: TF-IDF + cosine similarity
    • LiteEngine: lightweight normalized TF approach
  • yeny.storage:
    • MetadataStorage (recommended): SQLite WAL for metadata + .yny binaries for index data
    • JSONStorage: plain .json files (simple / debugging)
    • SQLiteStorage: full index serialized in SQLite tables
    • AlchemyStorage: full index serialized via SQLAlchemy (MySQL, PostgreSQL, etc.)
  • yeny.storage.DatabaseReader: read-only adapter for ingesting from your DB without creating any yeny_* tables
  • yeny.worker: async/periodic reindex worker (zero-downtime)
  • yeny.health: system and index health reporting
  • yeny.utils: NLP, indexing helpers, math, serialization, mmap helpers

Why Yeny?

Note: The comparison below is qualitative. Yeny benchmarks compare its own core and lite engines; they do not benchmark external projects.

Feature Yeny Whoosh Meilisearch Elasticsearch
Pure Python (zero deps) ✅ ✅ ❌ (Rust) ❌ (Java)
Direct DB table ingestion ✅ ❌ ❌ ❌
Temporal sharding ✅ ❌ ❌ ✅
Background worker ✅ ❌ ❌ ✅
Rollback / versioning ✅ ❌ ❌ ✅
Bilingual docs (EN + ES) ✅ ❌ ❌ ❌
Zero external services ✅ ✅ ❌ ❌

Where Yeny shines:

Yeny is built for small to medium projects that need search without the overhead of a full-blown search infrastructure. You don't need to spin up a separate server, configure clusters, or learn a new query DSL — just pip install yeny and you're done.

  • Small projects & prototypes — When your dataset is in the thousands or low millions of documents, Yeny gives you production-quality search without standing up an Elasticsearch or Meilisearch instance.
  • Embedded use cases — Ideal for CLI tools, desktop apps, or Python backends (Flask, FastAPI) that need search as a library, not a service.
  • High customizability — Swap tokenizers, inject your own preprocessors, or even bring external NLP libraries (spaCy, NLTK). Yeny adapts to your domain, not the other way around.
  • SQL-native data — If your data already lives in SQLite, MySQL, or PostgreSQL, Yeny ingests directly from tables or queries — no ETL pipeline needed.
  • Time-series corpora — Temporal sharding lets you query logs, emails, or articles by date range without loading everything into RAM.

Documentation

Yeny includes full documentation in Spanish and English.

Useful entry points:

Benchmarks

Yeny includes a deterministic local suite for comparing CoreEngine and LiteEngine with the same generated corpus, queries, and tokenizer:

python -m benchmarks run --profile tiny

It measures index construction, public search latency, JSON/SQLite persistence, .yny serialization and mmap loading, artifact size, and available RSS memory. Results are saved as timestamped JSON so runs can be validated and compared without overwriting previous data.

These benchmarks measure speed, resource use, and persistence fidelity—not search relevance or performance against other projects. See the English guide, the guía en español, or the runner quick reference. The published cross-platform campaign, raw results, generated reports, and presentation are available in the benchmark documentation package.

Testing

python -m pytest -q

Sponsor

Yeny is an open-source project. If this toolkit has saved you time or helped you build robust search features, consider supporting its ongoing development and maintenance.

💝 Sponsor Yeny on GitHub

Contributing

Contributions are welcome. Open an issue or submit a pull request.

Roadmap

Development moves step by step—prioritizing pure-Python ergonomics first, while progressively building optional native acceleration in parallel.

Planned Engines (Pure Python)

Engine Status Description
BM25Engine 🧪 Planned BM25 relevance scoring — better IDF saturation and document length normalization than TF-IDF. Ideal for general-purpose search.
NanoEngine / CountEngine 🧪 Planned Ultra-lightweight raw term-frequency (bag-of-words) engine with zero normalization overhead. Built for maximum speed in simple keyword-matching scenarios alongside LiteEngine.

Parallel Track: Rust Acceleration

Component Status Description
Rust Core & Tokenizers 🦀 In Progress Gradual integration of optional Rust bindings (via PyO3) developed in parallel to accelerate tokenization, inverted index construction, and scoring kernels while keeping the pure-Python fallback intact.

Tentative / Future Exploration

  • 🔬 Fuzzy & typo-tolerant search: Built-in Levenshtein/Damerau-Levenshtein matching integrated into the search pipeline.
  • 🔬 Faceted search: Filter results by metadata fields (category, date, author) alongside full-text scoring.
  • 🔬 Multi-language stemming: Optional stemming support for Spanish, English, and more.

Legend: 🧪 Planned = next in the pipeline · 🦀 In Progress = parallel track · 🔬 Tentative = long-term exploration

Dedication

In loving memory of my mother, Yeny.

This project is named after her as a tribute to her life, her warmth, and everything she taught me. Every line of code in Yeny is shared freely with the developer community in her honor—so that her name continues to build, connect, and help others create. ❤️

License

MIT License

Metadata

Release files for yeny 0.1.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 yeny 0.1.1
File Size Uploaded Provenance Actions
yeny-0.1.1.tar.gz 129.8 kB Without provenance Details for yeny-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for yeny 0.1.1
File Interpreter ABI Platform Actions
yeny-0.1.1-py3-none-any.whl Python 3 none any Details for yeny-0.1.1-py3-none-any.whl

Total release size: 281.1 kB

Release files / yeny-0.1.1.tar.gz

Download URL yeny-0.1.1.tar.gz
Size 129.8 kB
Tags Source
SHA-256 checksum
How to use checksums
011bfddc30f459d965ba33cbecb7cd30f13ad596d61abc017c9aa90d6c47af21
BLAKE2b-256 checksum
How to use checksums
d958b98ed2d89883a1c3512755d32791f4068dd51096e86cb2c5e486927161ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / yeny-0.1.1-py3-none-any.whl

Download URL yeny-0.1.1-py3-none-any.whl
Size 151.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c1b0c54d00be51c77d1bece8de53518bb798de2c1737cb7f4a741b4d922c531
BLAKE2b-256 checksum
How to use checksums
27a56c3c4026dc9c1c449115b54fbdfbed28db5e84548965795a8c02be97df5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for yeny 0.1.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.1.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