Skip to main content

Kinto Algolia

https://img.shields.io/travis/Kinto/kinto-algolia.svg https://img.shields.io/pypi/v/kinto-algolia.svg https://coveralls.io/repos/Kinto/kinto-algolia/badge.svg?branch=master

kinto-algolia forwards the records to Algolia and provides a /search endpoint to query the indexed data.

Install

pip install kinto-algolia

Setup

In the Kinto settings:

kinto.includes = kinto_algolia
kinto.algolia.application_id = YourApplicationID
kinto.algolia.api_key = YourAPIKey

# List of buckets/collections to show:
kinto.algolia.resources = /buckets/chefclub-v2
                          /buckets/chefclub/collections/recipes

By default, indices names are prefixed with kinto-. You change this with:

kinto.algolia.index_prefix = myprefix

Usage

Create a new record:

$ echo '{"data":
    {"id": "1008855320",
     "last_modified": 1523349594783,
     "title": "kinto",
     "description": "A database for the web",
     "_geoloc": {"lng": -73.778925, "lat": 40.639751}}' | \
    http POST http://localhost:8888/v1/buckets/example/collections/notes/records \
        --auth token:alice-token

It should now be possible to search for it using the Algolia API.

For example, using a quick querystring search:

$ http "http://localhost:8888/v1/buckets/example/collections/notes/search?query=kinto+database" \
    --auth token:alice-token

Or an advanced search using request body:

$ echo '{"insideBoundingBox": "46.650828100116044,7.123046875,45.17210966999772,1.009765625"}' | \
    http POST http://localhost:8888/v1/buckets/example/collections/notes/search \
        --auth token:alice-token
HTTP/1.1 200 OK
Access-Control-Expose-Headers: Retry-After, Content-Length, Alert, Backoff
Content-Length: 333
Content-Type: application/json; charset=UTF-8
Date: Wed, 20 Jan 2016 12:02:05 GMT
Server: waitress

{
  "hits": [
    {
       "_geoloc": {
           "lat": 40.639751,
           "lng": -73.778925
       },
       "_highlightResult": {
           "title": {
               "matchLevel": "none",
               "matchedWords": [],
               "value": "Kinto"
           }
       },
       "last_modified": 1523349594783,
       "title": "Kinto",
       "description": "A database for the web",
       "objectID": "1008855320"
    }
  ],
  "hitsPerPage": 1000,
  "nbHits": 1,
  "nbPages": 1,
  "page": 0,
  "params": "insideBoundingBox=42.124710287101955%2C9.335632324218752%2C41.47360232634395%2C14.403076171875002&hitsPerPage=10000&query=",
  "processingTimeMS": 2,
  "query": ""
}

Custom index settings

By default, Algolia infers the data types from the indexed records.

But it’s possible to define the index mappings (ie. schema) from the collection metadata, in the algolia:settings property:

$ echo '{
  "attributesToIndex": ["title", "description"]
}' | http PATCH "http://localhost:8888/v1/buckets/blog/collections/builds" \
    --auth token:admin-token --verbose

Refer to Algolia official documentation for more information about settings.

Running the tests

$ make tests

Changelog

1.1.0 (2019-04-26)

  • Upgrade to algoliasearch 2.0

1.0.0 (2019-02-08)

  • Add support for collections whitelist. (#6)

0.2.0 (2018-07-18)

Bug fixes

  • Update algolia settings.

0.1.1 (2018-06-06)

Bug fixes

  • Fix reindex command.

0.1.0 (2018-04-12)

New features

  • Flush indices when server is flushed

  • Perform insertions and deletion in bulk for better efficiency

  • Add heartbeat

  • Delete indices when buckets and collections are deleted

  • Support quick search from querystring

  • Support defining mapping from the algolia:settings property in the collection metadata

Bug fixes

  • Only index records if the storage transaction is committed

  • Do not allow to search if no read permission on collection or bucket

  • Fix empty results response when plugin was enabled after collection creation

Internal changes

  • Create index when collection is created

Release files for kinto-algolia 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kinto-algolia 1.1.0
File Size Uploaded
kinto-algolia-1.1.0.tar.gz 15.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kinto-algolia 1.1.0
File Interpreter ABI Platform
kinto_algolia-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.0 kB

Release files / kinto-algolia-1.1.0.tar.gz

Download URL kinto-algolia-1.1.0.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2661a2ceaebbfa41e89f4581c5faf294c9b7c7b172a3685c6eaaacd39bc37f96
BLAKE2b-256 checksum
How to use checksums
dce7f075f48b3bfce869ee8c088db6d1ad737d8a5f0ac2a809d1b5191cedb73e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.8.0 tqdm/4.19.7 CPython/3.6.7

Release files / kinto_algolia-1.1.0-py3-none-any.whl

Download URL kinto_algolia-1.1.0-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
841dae8a2424ee8d1e5574e687d0a90b4250790979f2ee75bcbd32fa16af9fd4
BLAKE2b-256 checksum
How to use checksums
1e61bb56558b11f48b11c81b93d2d107707af97936d4b432458388845267393a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.8.0 tqdm/4.19.7 CPython/3.6.7

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page