A pure-Python full text indexing search library based on sqlite and the FTS5 extension.
Project description
pocketsearch
pocketsearch is a pure-Python full text indexing search library based on SQLite and the FTS5 extension. It provides
- A simple API (inspired by the ORM layer of the Django web framework) for defining schemas and searching - no need to write SQL
- Multi-field indices using schemas including text, numeric and date/datetime search
- Prefix, phrase and initial token queries
- Spell checking
- Boolean search queries
- Highlightning search results and extracting snippets
- Autocomplete features
Pocketsearch does not have any dependencies other than Python (3.8 or higher).
Quick start
Install using PIP:
pip install pocketsearch
Pocketsearch requires Python 3.8 or higher.
Create a search index using a PocketWriter and store it to database my_db.db:
import pocketsearch
with pocketsearch.PocketWriter(db_name="my_db.db") as pocket_writer:
pocket_writer.insert(text="Hello world")
Open the search index using a PocketReader to perform searches:
import pocketsearch
with pocketsearch.PocketReader(db_name="my_db.db") as pocket_reader:
for result in pocket_reader.search(text="Hello world"):
print(result.text)
You can define custom schemas to create multi-field indices:
import pocketsearch as ps
class Product(ps.Schema):
price = ps.Int()
description = ps.Text(index=True) # part of full text (FT) index
category = ps.Text() # not part of FT index
with ps.PocketWriter(db_name="my_db.db",schema=Product) as pocket_writer:
pocket_writer.insert(description="Apple",category="Fruit",price=3.21)
pocket_writer.insert(description="Orange",category="Fruit",price=4.11)
with ps.PocketReader(db_name="my_db.db",schema=Product) as pocket_reader:
# Search for products with a price greater than or equal 3:
print(pocket_reader.search(price__gte=3).count())
Read the complete documentation at https://pocketsearch.readthedocs.io/
Status
The package is currently in Beta status.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pocketsearch-0.21.1.tar.gz
.
File metadata
- Download URL: pocketsearch-0.21.1.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bac1bbf21ed544bf48b73f59af214417aadd008e58b8289e9d02614acac9b8ce |
|
MD5 | 58fc91b8a9febb757592c8f5913ed3d0 |
|
BLAKE2b-256 | 6076e0115117347450d3f12948220e38c3ba6a434992e895b5317dd7b69ad1ff |
File details
Details for the file pocketsearch-0.21.1-py3-none-any.whl
.
File metadata
- Download URL: pocketsearch-0.21.1-py3-none-any.whl
- Upload date:
- Size: 33.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7696cbf29cb2a43d4ffeb65bc864b4fb36d2c4b247d503f8c9888e4f468e650 |
|
MD5 | 386a27401466bb9a087cb3aa39d864d3 |
|
BLAKE2b-256 | bcbaa29aeebe2c9e9f69a8197a9d285c1e989ceabbab48527ceb7d73f615bab2 |