Metadata-Version: 2.1
Name: django-searchable
Version: 0.1.1
Summary: Easy FTS with Django and PostgreSQL
Home-page: https://github.com/rjauquet/django-searchable
Author: Rob Ervin Jauquet
Author-email: rjauquet@gmail.com
License: UNKNOWN
Download-URL: https://github.com/rjauquet/django-searchable/archive/0.2.tar.gz
Keywords: search,searchable,fts
Platform: UNKNOWN

Django Searchable
=================

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 :code:`SearchableModel` class, and use the :code:`SearchableTextField` class to automatically setup full text search:

.. code-block:: python

    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:

.. code-block:: python

    # 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)

:code:`.search` adds a :code:`rank` annotation and automatically filters and sorts the resulting queryset.

By default, :code:`.search` will search through all :code:`SearchableTextField` fields on the model, but you can specify any subset:

.. code-block:: python

    results = Blog.objects.search('who is venom', fields=['title'])

Contributing
--------------

.. code-block:: bash

    pipenv install --dev
    createuser -s -P test_user  # use 'password'
    pipenv run ./manage.py test


