/django-algolia

Synchronize your models with the Algolia API for easier and faster searches

Primary LanguagePythonBSD 2-Clause "Simplified" LicenseBSD-2-Clause

django-algolia

Synchronize your models with the Algolia API for easier and faster searches. :warning: Be aware that this project is no longer maintained!

=> Documentation

Documentation Status Travis CI Status

Compatibilities & Requirements

  • algoliasearch >= 1.5.2
Language 2.7 3.4
Python V X
Framework 1.6 1.7 1.8
Django V X X

The compatibility to the latest versions are planned, you can participate if you want : Feel free to open an issue.

# TL;DR

  • Install the app:
pip install -e git+https://github.com/Kmaschta/django-algolia.git#egg=dev
  • Register to Algolia and make configure your settings:
INSTALLED_APPS = [
  # [...]
  'algolia',
]

ALGOLIA = {
  'API_KEY': '******',
  'API_SECRET': '*********************',
}
  • Specify what models and what fields should be indexed
class MyPony(models.Model):
  ALGOLIA_INDEX_FIELDS = ('name', 'clogs_number',)

  name = models.CharField(max_length=255)
  clogs_number = models.IntegerField()
  • Load database migrations:
./manage.py migrate
  • Build remote index (you don't have to do it twice)
./manage.py rebuild_algolia_index --model=MyPony
  • Search your datas
from algolia import AlgoliaIndexer
from my.project.models import MyPony
indexer = AlgoliaIndexer()
results = indexer.search(MyPony, 'Rainbow Dash')

# results content
{
    u'hits': [
      {...}
    ],
    u'processingTimeMS': 1,
    u'nbHits': 0,
    u'hitsPerPage': 20,
    u'params':
    u'query=Rainbow Dash',
    u'nbPages': 0,
    u'query': u'',
    u'page': 0,
}