Easy FTS with Django and PostgreSQL
Project description
Easy full text search with Django and PostgreSQL. Sane defaults + auto creation of vector fields, indexes, and database triggers.
Example
Extend your model with the SearchableModel class, and use the SearchableTextField class to automatically setup full text search:
from django.db.models import TextField
from django_searchable.models import SearchableModel, SearchableTextField
class Blog(SearchableModel):
author_name = TextField() # will NOT have FTS setup automatically
title = SearchableTextField() # will have FTS setup automatically
text = SearchableTextField() # will have FTS setup automatically
Then search away via the Blog manager:
# takes a string of space separated terms
results = Blog.objects.search('spiderman suits')
# or a list of terms
results = Blog.objects.search(['water', 'baskets', 'leaking'])
# or a SearchQuery object
from django.contrib.postgres.search import SearchQuery
query = ~SearchQuery('superman') & SearchQuery('batman')
results = Blog.objects.search(query)
.search adds a rank annotation and automatically filters and sorts the resulting queryset.
By default, .search will search through all SearchableTextField fields on the model, but you can specify any subset:
results = Blog.objects.search('who is venom', fields=['title'])
Contributing
pipenv install --dev
createuser -s -P test_user # use 'password'
pipenv run ./manage.py test
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_searchable-0.1.2.tar.gz.
File metadata
- Download URL: django_searchable-0.1.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8ccae2ae637c4ffc3e17600d2fe2ef8034ea143d8a50b97c731b9eee77837d6
|
|
| MD5 |
00b22dcb357979e4ebfbcd477cf61be5
|
|
| BLAKE2b-256 |
67dd836717f388b765477dec31e0da98e4174003b6206d6e1f3fbaf17ba329ad
|
File details
Details for the file django_searchable-0.1.2-py3-none-any.whl.
File metadata
- Download URL: django_searchable-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b09d691b3b786c309faf8bad099abc6eec653e4abc9e0d127b6154c1292a4a2
|
|
| MD5 |
21cef019b198b785365e952aea32c3be
|
|
| BLAKE2b-256 |
753092dccb2dd9b1be9d0c2c77d021d0202c0de23a94a547e9c5438069a46c55
|