Skip to content

Commit b3f5378

Browse files
committed
Merge branch 'master' into develop
2 parents 9b97360 + 1437f5c commit b3f5378

File tree

9 files changed

+421
-56
lines changed

9 files changed

+421
-56
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ var/
2323
.installed.cfg
2424
*.egg
2525

26+
# IDE Files
27+
*.iml
28+
.idea/
29+
2630
# PyInstaller
2731
# Usually these files are written by a python script from a template
2832
# before PyInstaller builds the exe, so as to inject date/other infos into it.

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ env:
1010
matrix:
1111
- TOXENV=py27-django17
1212
- TOXENV=py27-django18
13+
- TOXENV=py27-django19
1314
- TOXENV=py33-django17
1415
- TOXENV=py33-django18
16+
- TOXENV=py33-django19
1517
- TOXENV=py34-django17
1618
- TOXENV=py34-django18
19+
- TOXENV=py34-django19
20+
- TOXENV=py35-django18
21+
- TOXENV=py35-django19
1722
- TOXENV=py36-django18
23+
- TOXENV=py36-django19
1824
- TOXENV=coveralls
1925
global:
2026
- secure: upiNM5+0o3+OnDmkNUhIiytQwIvDsT/rYuC0yrE3cwQV/UgzYBn66YAO03aBBheL6jjqyzteqKnSAm/sNJ7wPkH4brebG6JPWOYMLa2EPdRRfA+Ztxz8ZwKDwQ8syzsdUiw8aHwcPNB0Uc2wO2cUbBKyq6SfVHGJXDVIsViZgnl8CO3KpvwYJ8gj1aj1GQh7aR7y7lsXuTlO9/uFO3AQS6iIJ5QbWPDtjuFdz31xZbW2nIVIv1pQ/OgKsGt0gyLZ1KzirXv9+5enyqQd3ZdVZVTp516Cyxah2bKFQ0shUVDPrLoHQ3iXKUynV1kEzCcqNa4Icu6JfOIyddB0F1NC6FPkUkhnBIrONrCjWBCbUJFHPBCGzmmtSGGXbcQ9zJXFiTmop2P5aWLyvGpavaH840mz/zRLBCpjACGuuB91+pUdvkTHufia1TUW+KN+YSyXyOPPo8a2HvQb3Hj9ehaxKM7yqdL+DeeCXqZDX6U2UGjrLwPEFMdSojm2c8kDBXN7tI/Gi+TiWsnbn9kBHYt9ZWZRdZ4gN95X8KPaoJu4YC9mxmsG83DEUlM+3otyymSqRqp3x8aEHIfw7+Myxvr2rcb4ul8pQ0ps0MGeZDTMa69FQejrS8CZfw5CUG5rwYLHBijE2+gW4r1HgHv2Yz0MPimAQJ98nTon8gsDmxAIsAk=

ChangeLog

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CHANGELOG
22

3-
2015-07-XX X.X.X
3+
2017-04-27 X.X.X
44
* [CHANGE] Module name to avoid conflict when installing the package with pip
55
* [CHANGE] Big performance improvements
66
* [ADD] Option to raise or not exceptions. By default, raise only when DEBUG=True
@@ -9,6 +9,18 @@ CHANGELOG
99
* [FIX] algolia_reindex command with batchsize argument on python34-django18
1010
* [FIX] Fields syntax
1111

12+
2017-01-20
13+
* [FIX] Default to model.pk instead of 'id'
14+
15+
2016-04-15 1.2.4
16+
* [FIX] Fix --batch-size of reindex command on Django 1.7
17+
18+
2015-12-15 1.2.3
19+
* [FIX] Check that geo_field callable returns something valid
20+
21+
2015-12-03 1.2.2
22+
* [FIX] Compatibility warning with Django 1.9
23+
1224
2015-07-09 1.2.1
1325
* [ADD] `get_queryset` for grain indexing possibility
1426
* [ADD] Option to deactivate auto-indexing

README.md

Lines changed: 104 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,74 @@
1-
Algolia Search for Django
2-
==================
1+
# Algolia Search API Client for Django
2+
3+
[Algolia Search](https://www.algolia.com) is a hosted full-text, numerical, and faceted search engine capable of delivering realtime results from the first keystroke.
4+
5+
[![Build Status](https://travis-ci.org/algolia/algoliasearch-django.svg?branch=master)](https://travis-ci.org/algolia/algoliasearch-django)
6+
[![Coverage Status](https://coveralls.io/repos/algolia/algoliasearch-django/badge.svg?branch=master)](https://coveralls.io/r/algolia/algoliasearch-django)
7+
[![PyPI version](https://badge.fury.io/py/algoliasearch-django.svg?branch=master)](http://badge.fury.io/py/algoliasearch-django)
8+
39

410
This package lets you easily integrate the Algolia Search API to your [Django](https://www.djangoproject.com/) project. It's based on the [algoliasearch-client-python](https://github.com/algolia/algoliasearch-client-python) package.
511

612
You might be interested in this sample Django application providing a typeahead.js based auto-completion and Google-like instant search: [algoliasearch-django-example](https://github.com/algolia/algoliasearch-django-example)
713

8-
Compatible with **Python 2.7**, **Python 3.3+** and **Django 1.7+**
914

10-
[![Build Status](https://travis-ci.org/algolia/algoliasearch-django.svg?branch=master)](https://travis-ci.org/algolia/algoliasearch-django)
11-
[![Coverage Status](https://coveralls.io/repos/algolia/algoliasearch-django/badge.svg?branch=master)](https://coveralls.io/r/algolia/algoliasearch-django)
12-
[![PyPI version](https://badge.fury.io/py/algoliasearch-django.svg?branch=master)](http://badge.fury.io/py/algoliasearch-django)
1315

14-
Table of Content
15-
-------------
16-
**Get started**
1716

18-
1. [Install](#install)
19-
1. [Setup](#setup)
20-
1. [Quick Start](#quick-start)
21-
1. [Commands](#commands)
22-
1. [Search](#search)
23-
1. [Geo-search](#geo-search)
24-
1. [Tags](#tags)
25-
1. [Options](#options)
17+
## API Documentation
18+
19+
You can find the full reference on [Algolia's website](https://www.algolia.com/doc/api-client/django/).
20+
21+
22+
## Table of Contents
23+
24+
25+
1. **[Setup](#setup)**
26+
27+
* [Install](#install)
28+
* [Setup](#setup)
29+
* [Quick Start](#quick-start)
30+
31+
1. **[Commands](#commands)**
32+
33+
* [Commands](#commands)
34+
35+
1. **[Search](#search)**
36+
37+
* [Search](#search)
38+
39+
1. **[Geo-Search](#geo-search)**
40+
41+
* [Geo-Search](#geo-search)
42+
43+
1. **[Tags](#tags)**
44+
45+
* [Tags](#tags)
46+
47+
1. **[Options](#options)**
48+
49+
* [Custom `objectID`](#custom-objectid)
50+
* [Custom index name](#custom-index-name)
51+
* [Index settings](#index-settings)
52+
* [Restrict indexing to a subset of your data](#restrict-indexing-to-a-subset-of-your-data)
53+
54+
1. **[Tests](#tests)**
55+
56+
* [Run Tests](#run-tests)
57+
58+
59+
60+
61+
# Setup
62+
2663

2764

28-
Install
29-
-------------
65+
## Install
3066

3167
```sh
3268
pip install algoliasearch-django
3369
```
3470

35-
Setup
36-
-------------
71+
## Setup
3772

3873
In your Django settings, add `algoliasearch_django` to `INSTALLED_APPS` and add these two settings:
3974

@@ -44,16 +79,15 @@ ALGOLIA = {
4479
}
4580
```
4681

47-
There are two optional settings:
82+
There are three optional settings:
4883

4984
* `INDEX_PREFIX`: prefix all indexes. Use it to separate different applications, like `site1_Products` and `site2_Products`.
5085
* `INDEX_SUFFIX`: suffix all indexes. Use it to differenciate development and production environment, like `Location_dev` and `Location_prod`.
5186
* `AUTO_INDEXING`: automatically synchronize the models with Algolia (default to **True**).
5287

53-
Quick Start
54-
-------------
88+
## Quick Start
5589

56-
Simply call `AlgoliaSearch.register()` for each of the models you want to index. A good place to do this is in your application's AppConfig (generally named `apps.py`). More info in the [documentation](https://docs.djangoproject.com/en/1.8/ref/applications/)
90+
Simply call `algoliasearch.register()` for each of the models you want to index. A good place to do this is in your application's AppConfig (generally named `apps.py`). More info in the [documentation](https://docs.djangoproject.com/en/1.8/ref/applications/)
5791

5892
```python
5993
from django.apps import AppConfig
@@ -81,21 +115,32 @@ from algoliasearch_django import AlgoliaIndex
81115
class YourModelIndex(AlgoliaIndex):
82116
fields = ('name', 'date')
83117
geo_field = 'location'
84-
settings = {'attributesToIndex': ['name']}
118+
settings = {'searchableAttributes': ['name']}
85119
index_name = 'my_index'
86120
```
87121

88122
And then replace `register(YourModel)` with `register(YourModel, YourModelIndex)`.
89123

124+
125+
# Commands
126+
127+
128+
90129
## Commands
91130

92131
* `python manage.py algolia_reindex`: reindex all the registered models. This command will first send all the record to a temporary index and then moves it.
132+
* you can pass ``--model`` parameter to reindex a given model
93133
* `python manage.py algolia_applysettings`: (re)apply the index settings.
94134
* `python manage.py algolia_clearindex`: clear the index
95135

136+
137+
# Search
138+
139+
140+
96141
## Search
97142

98-
We recommend the usage of our [JavaScript API Client](https://github.com/algolia/algoliasearch-client-js) to perform queries directly from the end-user browser without going through your server.
143+
We recommend the usage of our [JavaScript API Client](https://github.com/algolia/algoliasearch-client-javascript) to perform queries directly from the end-user browser without going through your server.
99144

100145
However, if you want to search from your backend you can use the `raw_search(YourModel, 'yourQuery', params)` method. It retrieves the raw JSON answer from the API.
101146

@@ -106,6 +151,11 @@ params = { "hitsPerPage": 5 }
106151
raw_search(Contact, "jim", params)
107152
```
108153

154+
155+
# Geo-Search
156+
157+
158+
109159
## Geo-Search
110160

111161
Use the `geo_field` attribute to localize your record. `geo_field` should be a callable that returns a tuple (latitude, longitude).
@@ -119,17 +169,20 @@ class Contact(models.model):
119169
def location(self):
120170
return (self.lat, self.lng)
121171

122-
123172
class ContactIndex(AlgoliaIndex):
124173
fields = 'name'
125174
geo_field = 'location'
126175

127-
128176
algoliasearch.register(Contact, ContactIndex)
129177
```
130178

179+
131180
# Tags
132181

182+
183+
184+
## Tags
185+
133186
Use the `tags` attributes to add tags to your record. It can be a field or a callable.
134187

135188
```python
@@ -139,8 +192,11 @@ class ArticleIndex(AlgoliaIndex):
139192

140193
At query time, specify `{ tagFilters: 'tagvalue' }` or `{ tagFilters: ['tagvalue1', 'tagvalue2'] }` as search parameters to restrict the result set to specific tags.
141194

195+
142196
# Options
143197

198+
199+
144200
## Custom `objectID`
145201

146202
You can choose which field will be used as the `objectID `. The field should be unique and can be a string or integer. By default, we use the `pk` field of the model.
@@ -161,12 +217,13 @@ class ContactIndex(algoliaindex):
161217

162218
## Index settings
163219

164-
We provide many ways to configure your index allowing you to tune your overall index relevancy. All the configuration is explained on [our website](https://www.algolia.com/doc/python#Settings).
220+
We provide many ways to configure your index allowing you to tune your overall index relevancy.
221+
All the configuration is explained on [our doc](https://www.algolia.com/doc/api-client/python/parameters/).
165222

166223
```python
167224
class ArticleIndex(AlgoliaIndex):
168225
settings = {
169-
'attributesToIndex': ['name', 'description', 'url'],
226+
'searchableAttributes': ['name', 'description', 'url'],
170227
'customRanking': ['desc(vote_count)', 'asc(name)']
171228
}
172229
```
@@ -186,3 +243,19 @@ class Contact(models.model):
186243
class ContactIndex(AlgoliaIndex):
187244
should_index = 'is_adult'
188245
```
246+
247+
248+
# Tests
249+
250+
251+
252+
## Run Tests
253+
254+
To run the tests, first find your Algolia application id and Admin API key (found on the Credentials page).
255+
256+
```shell
257+
ALGOLIA_APPLICATION_ID={APPLICATION_ID} ALGOLIA_API_KEY={ADMIN_API_KEY} tox
258+
```
259+
260+
261+

0 commit comments

Comments
 (0)