django-pg-fts
=============
Implementation PostgeSQL for Full Text Search for django 1.7, taking advantage of new features Migrations and Custom Lookups.
Features:
- FieldLookup's search, isearch, tsquery
- Ranking support with normalization, and weights using annotations
- Migrations classes to help create and remove index's, support for 'gin' or 'gist'
- Migrations classes to help create and remove of trigger's
- Multiple dictionaries support with trigger and FieldLookup's
- Support for python 2.7, 3.3 and 3.4
With multiple dictionary support, index and trigger migrations
How it works
------------
For a existing model::
class Article(models.Model):
title = models.CharField(max_length=255)
article = models.TextField()
You want to have full text search in fields title and article, and make give weight to title of 'A'.
Import TSVectorField::
from pg_fts.fields import TSVectorField
Add to existing TSVectorField to model and tell the fields that you want to index and the dictionary::
fts = TSVectorField(fields=(('title', 'A'), 'article'), dictionary='english')
Create migrations file::
python manage.py makemigrations article
Open the new created migration and import CreateFTSIndexOperation, CreateFTSTriggerOperation, UpdateVectorOperation::
from pg_fts.migrations import (CreateFTSIndexOperation, CreateFTSTriggerOperation,
UpdateVectorOperation)
And add to the end of operations::
# update vector for already existing data
UpdateVectorOperation(
name='Article',
field='fts',
),
# create trigger for automatic insert and update vector
CreateFTSTriggerOperation(
name='Article',
field='fts'
),
# create gin index for vector
CreateFTSIndexOperation(
name='Article',
field='fts',
index='gin'
)
Make the changes to your database::
python manage.py migrate article
Now you have a full text search performance with a trigger that checks any changes in the tracked fields and updates vector field.
You can search will match all words:
>>> Article.objects.filter(fts__search='waz up')
Will result in sql something like:
.. code-block:: sql
tsvector @@ to_tsquery('english', 'waz & up')
Or isearch will match some words:
>>> Article.objects.filter(fts__isearch='waz up')
Will result in sql something like:
.. code-block:: sql
tsvector @@ to_tsquery('english', 'waz | up')
But you can make a raw tsquery:
>>> Article.objects.filter(fts__tsquery='waz & !up')
Will result in sql something like:
.. code-block:: sql
tsvector @@ to_tsquery('english', 'waz & !up')
And also rank the results with normalization and order:
>>> from pg_fts.ranks import FTSRank
>>> Article.objects.filter(
rank=FTSRank(fts_search='waz up', normalization=[1,3])).order_by('-rank')
For multiple dictionaries and more advanced options, check the `documentation <http://django-pg-fts.readthedocs.org/>`_.
Documentation
-------------
Documentation available in `Read The Docs django-pg-fts.readthedocs.org <http://django-pg-fts.readthedocs.org/>`_
Installation
------------
Clone from GitHub::
git clone git://github.com/dvdmgl/django-pg-fts.git django-pg-fts
You should run the tests::
python runtests.py
Or running tox for py27, py33, py34::
tox
Install using pip from github::
pip install git+https://github.com/dvdmgl/django-pg-fts
Or using setup.py::
python setup.py
Metadata
Release files for django-pg-fts 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-pg_fts-0.1.1.tar.gz | 28.4 kB | Without provenance | Details for django-pg_fts-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_pg_fts-0.1.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for django_pg_fts-0.1.1-py2.py3-none-any.whl |
Total release size: 43.0 kB
Release files / django-pg_fts-0.1.1.tar.gz
| Download URL | django-pg_fts-0.1.1.tar.gz |
|---|---|
| Size | 28.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8bd1df25e7006ac7faf41d68507384044a8cc6b6ed4a9e119d32c0a16dbc73cc
|
|
BLAKE2b-256 checksum How to use checksums |
fa14ad2ff4ac3980f4a61daf4b15b7d5f498c5e228267f2fcb3e5d558df3032c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_pg_fts-0.1.1-py2.py3-none-any.whl
| Download URL | django_pg_fts-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 14.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
e7249b405930dd04b65633dfce4e0aaae28875172df2dc83c5506451e3d81114
|
|
BLAKE2b-256 checksum How to use checksums |
9e38bb732ae4377709d8728e02454010af00a099830a5a055d3b2608d10b8da3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-pg-fts 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.