Skip to main content

Simple full-text search library with SQL backend

Project description

Sifts – Simple Full Text Search

Sifts is a simple Python full text search engine library with an SQLite or PostgreSQL backend.

It is meant to be used with Python libraries that need full-text search support, but where deploying something like ElasticSearch is overkill.

It supports both SQLite FTS5 and PostgreSQL FTS as backends.

Installation

pip install sifts

Usage

import sifts

# by default, creates a new SQLite database in the working directory
collection = sifts.Collection(name="my_collection")

# Add docs to the index. Can also update and delete.
collection.add(
    documents=["Lorem ipsum dolor", "sit amet"],
    metadatas=[{"foo": "bar"}, {"foo": "baz"}], # otpional, can filter on these
    ids=["doc1", "doc2"], # unique for each doc. Uses UUIDs if omitted
)

results = collection.query(
    "Lorem",
    # limit=2,  # optionally limit the number of results
    # where={"foo": "bar"},  # optional filter
    # order_by="foo",  # sort by metadata key (rather than rank)
)

The API is inspired by chroma.

Search Syntax

Sifts supports the following search syntax:

  • Search for individual words
  • Search for multiple words (will match documents where all words are present)
  • and operator
  • or operator
  • * wildcard (in SQLite, supported anywhere in the search term, in PostgreSQL only at the end of the search term)

The search syntax is the same regardless of backend.

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

sifts-0.8.3.tar.gz (13.9 kB view hashes)

Uploaded Source

Built Distribution

sifts-0.8.3-py3-none-any.whl (8.2 kB view hashes)

Uploaded Python 3

Supported by

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