Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use elasticsearch 5
Artur Smęta24e5b2d036d
diff --git a/docker-compose.yml b/docker-compose.ymlindex 1a6588b2c9..6d36ce2be1 100755--- a/docker-compose.yml+++ b/docker-compose.yml@@ -12,7 +12,7 @@ services:ports:- '6379:6379'search:- image: elasticsearch:2.4+ image: elasticsearch:5.1.1ports:- '9200:9200'web:diff --git a/saleor/search/backends/dashboard.py b/saleor/search/backends/dashboard.pyindex c40125e67d..9a320d30d0 100644--- a/saleor/search/backends/dashboard.py+++ b/saleor/search/backends/dashboard.py@@ -1,4 +1,4 @@-from . import elasticsearch2+from . import elasticsearch5from .base import BaseSearchQueryfrom ..index import get_indexed_models@@ -64,7 +64,7 @@ class DashboardSearchQuery(BaseSearchQuery):return self.get_inner_query()-class DashboardSearchResults(elasticsearch2.Elasticsearch2SearchResults):+class DashboardSearchResults(elasticsearch5.Elasticsearch5SearchResults):def _do_search(self):# Params for elasticsearch query@@ -118,8 +118,20 @@ class DashboardSearchResults(elasticsearch2.Elasticsearch2SearchResults):return body+ def _do_count(self):+ # Get count+ hit_count = self.backend.es.count(+ body=self._get_es_body(for_count=True),+ )['count']+ # Add limits+ hit_count -= self.start+ if self.stop is not None:+ hit_count = min(hit_count, self.stop - self.start)++ return max(hit_count, 0)+-class DashboardMultiTypeSearchBackend(elasticsearch2.Elasticsearch2SearchBackend):+class DashboardMultiTypeSearchBackend(elasticsearch5.Elasticsearch5SearchBackend):results_class = DashboardSearchResultsquery_class = DashboardSearchQuerydiff --git a/saleor/search/backends/elasticsearch.py b/saleor/search/backends/elasticsearch.pyindex c770ea534b..7fa6a658a7 100644--- a/saleor/search/backends/elasticsearch.py+++ b/saleor/search/backends/elasticsearch.py@@ -470,7 +470,6 @@ class ElasticsearchSearchResults(BaseSearchResults):index=self.backend.get_index_for_model(self.query.queryset.model).name,body=self._get_es_body(for_count=True),)['count']-# Add limitshit_count -= self.startif self.stop is not None:diff --git a/saleor/settings.py b/saleor/settings.pyindex e8cc19122b..39e5c3f3a3 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -330,7 +330,7 @@ ES_URL = ELASTICSEARCH_URL or SEARCHBOX_URL or BONSAI_URL or ''if ES_URL:SEARCH_BACKENDS = {'default': {- 'BACKEND': 'saleor.search.backends.elasticsearch2',+ 'BACKEND': 'saleor.search.backends.elasticsearch5','URLS': [ES_URL],'INDEX': os.environ.get('ELASTICSEARCH_INDEX_NAME', 'storefront'),'TIMEOUT': 5,