Skip to main content

Logo

Scruby-FTS

Plugin for Scruby - Full-text search with Manticore Search.

Docs PyPI pyversions PyPI status PyPI version fury.io
Types: Pyrefly Code style: Ruff Format PyPI Downloads License: MIT License: GPL v3

Scruby-FTS is a plugin for the Scruby project.


Documentation

Requirements

Installation

# For Scruby version 0
uv add "scruby-fts>=0.10.0,<1.0.0"
# For Scruby version 1
uv add "scruby-fts>=1.0.0,<2.0.0"
# For Scruby version 2
uv add "scruby-fts>=2.0.0,<3.0.0"
# For Scruby version 3
uv add "scruby-fts>=3.0.0,<4.0.0"
# For Scruby version 4
uv add "scruby-fts>=4.0.0,<5.0.0"

For more information, see the documentation.

  • Fedora 42 or later
# Install the repository:
sudo tee /etc/yum.repos.d/manticore.repo << "EOF" > /dev/null
[manticore]
name=Manticore Repository
baseurl=https://repo.manticoresearch.com/repository/manticoresearch/release/centos/10/$basearch
gpgcheck=1
enabled=1
gpgkey=https://repo.manticoresearch.com/GPG-KEY-SHA256-manticore
EOF

# Install Manticore Search:
sudo dnf install manticore manticore-extra
# Install English, German, and Russian lemmatizers:
sudo dnf install manticore-language-packs

# Run Manticore Search:
sudo systemctl start manticore
sudo systemctl enable manticore
sudo systemctl status manticore --no-pager -l

Usage

Examples

import anyio
from typing import Annotated, Any
from pydantic import Field
from scruby import ReturnType, Scruby, ScrubyModel
from scruby_fts import FullTextSearch, FTSConfig


class Car(ScrubyModel):
    """Car model."""

    brand: str = Field(frozen=True)
    model: str = Field(frozen=True)
    year: int
    power_reserve: int
    description: str
    # key is always at bottom
    key: Annotated[
        str,
        Field(
            frozen=True,
            default_factory=lambda data: f"{data['brand']}:{data['model']}",
        ),
    ]


async def main() -> None:
    """Example."""
    # Activate database.
    Scruby.run(plugins=[FullTextSearch])

    # Delete unnecessary tables that remain due to errors
    await FullTextSearch.delete_orphaned_tables()

    # Get collection `Car`
    car_coll = Scruby(Car)
    # Create cars.
    for num in range(1, 10):
        car = Car(
            brand="Mazda",
            model=f"EZ-6 {num}",
            year=2025,
            power_reserve=600,
            description="Electric cars are the future of the global automotive industry.",
        )
        await car_coll.add_doc(car)

    # Find car
    car: Car | None = await car_coll.plugins.fullTextSearch.find_one(
        morphology=FTSConfig.morphology.get("English"),  # 'English' or 'en'
        full_text_filter=("model", "EZ-6 9"),
    )

    # Return car in JSON format
    car: str | None = await car_coll.plugins.fullTextSearch.find_one(
        morphology=FTSConfig.morphology.get("English"),  # 'English' or 'en'
        full_text_filter=("model", "EZ-6 9"),
        return_type=ReturnType.JSON,
    )

    # Return car in Dictionary format
    car: dict | None = await car_coll.plugins.fullTextSearch.find_one(
        morphology=FTSConfig.morphology.get("English"),  # 'English' or 'en'
        full_text_filter=("model", "EZ-6 9"),
        return_type=ReturnType.DICT,
    )

    # Fand cars
    cars: list[Car] | None = await car_coll.plugins.fullTextSearch.find_many(
        morphology=FTSConfig.morphology.get("en"),  # 'en' or 'English'
        full_text_filter=("description", "future of automotive"),
    )

    # Return cars in JSON format
    cars: str | None = await car_coll.plugins.fullTextSearch.find_many(
        morphology=FTSConfig.morphology.get("en"),  # 'en' or 'English'
        full_text_filter=("description", "future of automotive"),
        return_type=ReturnType.JSON,
    )

    # Return cars in Dictionary format
    cars: list[dict] | None = await car_coll.plugins.fullTextSearch.find_many(
        morphology=FTSConfig.morphology.get("en"),  # 'en' or 'English'
        full_text_filter=("description", "future of automotive"),
        return_type=ReturnType.DICT,
    )

    # Full database deletion.
    # Hint: The main purpose is tests.
    Scruby.napalm()


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

Changelog

MIT

GPL-3.0

Metadata

Release files for scruby-fts 4.1.0

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

Built distribution (wheel)

Table of built distributions (wheels) for scruby-fts 4.1.0
File Interpreter ABI Platform
scruby_fts-4.1.0-py3-none-any.whl Python 3 none any Details

Release files / scruby_fts-4.1.0-py3-none-any.whl

Download URL scruby_fts-4.1.0-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87de4163830be7a73a5fd200c72921f69b15461721aadbe68e1cf15d8f9d5f4b
BLAKE2b-256 checksum
How to use checksums
b1f7e4276308ac19cf81934e8d70908a22b1eabc4e10d8f28acde6942b66d19a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

4.1.0 This release

1 release file

4.0.1

1 release file

4.0.0

1 release file

3.1.0

1 release file

3.0.1

1 release file

3.0.0

1 release file

2.2.5

1 release file

2.2.4

1 release file

2.2.3

1 release file

2.2.2

1 release file

2.2.1

1 release file

2.2.0

1 release file

2.1.0

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.10.0

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.0

1 release file

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