Users of Django/django-elasticsearch-dsl can easily integrate with Bonsai Elasticsearch! This library is built on top of elasticsearch-dsl which is built on top of the low level elasticsearch-py maintained by Elastic.
Let's get started:
Adding the libraries
You'll need to add the django-elasticsearch-dsl library to your requirements.txt file:
django-elasticsearch-dsl>=0.5.1
elasticsearch-dsl>=6.0,<6.2
Full Instructions can be found here
Connecting to Bonsai
Bonsai requires basic authentication for all read/write requests. You'll need to configure the client so that it
includes the username and password when communicating with the cluster. We recommend adding the cluster URL to an
environment variable, BONSAI_URL, to avoid hard-coding your authentication credentials.
The following code is a good starter for integrating Bonsai Elasticsearch into your app:
ES_URL = urlparse(os.environ.get('BONSAI_URL') or 'http://127.0.0.1:9200/')
ELASTICSEARCH_DSL={
'default': {
'hosts': ES_URL
},
}
Note about ports
The sample code above uses port 443, which is the default for the https:// protocol. If you're not using SSL/TLS and want to use http:// instead, change this value to 80.
Ready to take a closer look at Bonsai?
Find out if Bonsai is a good fit for you in just 15 minutes.