Skip to main content

Full-text search with Manticore Search.

Project description

scruby - full text

Full-text search with Manticore Search.

Build Status Docs PyPI pyversions PyPI status PyPI version fury.io
Types: Pyrefly Code style: Ruff Format PyPI Downloads GitHub license

Scruby-Full-Text is a plugin for the Scruby project.


Documentation

Online browsable documentation is available at https://kebasyaty.github.io/scruby-full-text/.

Requirements

View the list of requirements.

Installation

uv add scruby-full-text

Usage

See more examples here https://kebasyaty.github.io/scruby-full-text/latest/pages/usage/.

import anyio
from typing import Any
from pydantic import Field
from scruby import Scruby, ScrubyModel
from scruby import settings as scruby_settings
from scruby_full_text import FullText
from scruby_full_text import settings as full_text_settings
from pprint import pprint as pp

# Plugins connection.
scruby_settings.PLUGINS = [
    FullText,
]


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


def main() -> None:
    # Get collection `Car`
    car_coll = await Scruby.collection(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 one car
    car = await car_coll.plugins.fullText.find_one(
        morphology=full_text_settings.MORPHOLOGY.get("English"),  # 'English' or 'en'
        full_text_filter=("model", "EZ-6 9"),
    )
    if car is not None:
      pp(car)
    else:
      print("Not Found")

    # Fand many cars
    car_list = await car_coll.plugins.fullText.find_many(
        morphology=full_text_settings.MORPHOLOGY.get("en"),  # 'en' or 'English'
        full_text_filter=("description", "future of automotive"),
    )
    if car_list is not None:
      pp(car_list)
    else:
      print("Not Found")

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


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

Changelog

View the change history.

License

This project is licensed under the MIT.

This project is licensed under the GPL-3.0-or-later.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

scruby_full_text-0.2.0-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file scruby_full_text-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: scruby_full_text-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"42","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for scruby_full_text-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32ecd676f5d5cc551915a10a24a2af3d903788f75ac513dcb8c182dc2334f9c7
MD5 ef0166620b1d00d39c1c2fbb36cbba8f
BLAKE2b-256 17766e73016974c237818c67c737c9553957f244e2ac4799d9dc1a3935afc061

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