Elasticsearch search backend requires an Elasticsearch server. For development purposes docker-compose will create a Docker container running an Elasticsearch server instance.
Integration can be configured with set of environment variables. When you’re deploying on Heroku - you can use add-on that provides Elasticsearch as a service. By default Saleor uses Elasticsearch 2.4, but integration is compatibile with Elasticsearch 5 as well Services available on Heroku:
If you’re deploying somewhere else, you can use one of following services:
URL to elasticsearch engine. If it’s empty - search will be not available.
- Controls elasticsearch index name where all searchable documents will be stored. Defaults to
storefront. Index will be created automatically with first indexing.
Saleor modified wagtailsearch app from Wagtail to provide search. Core search concepts are preserved, only elasticsearch backends are available. Dashboard uses custom backend that searches in all available indexes. Initial search index can be created with following command:
$ python manage.py update_index
By default products are reindexed after saving forms in the dashboard. Orders are updated after they’re placed.
Search integration architecture¶
There are three base classes that are handling whole communication between Saleor and Elasticsearch service.
- ElasticsearchSearchBackend - Core implementation of elasticsearch communication. Here is the starting point of any search queries.
- ElasticsearchSearchQuery - Abstration for queries passed to elasticsearch. Any filtering or aggregations should be implemented there.
- ElasticsearchSearchResults - Abstration for search results