Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Align elastic search backend with new data scheme

Jakub Draganek91e3335f9f1a
diff --git a/saleor/search/backends/elasticsearch.py b/saleor/search/backends/elasticsearch.py
index 6113b7c0ef..25229bb468 100644
--- a/saleor/search/backends/elasticsearch.py
+++ b/saleor/search/backends/elasticsearch.py
@@ -447,8 +447,8 @@ class ElasticsearchSearchResults(BaseSearchResults):
hits = self.backend.es.search(**params)
# Get pks from results
- pks = [hit['fields']['pk'][0] for hit in hits['hits']['hits']]
- scores = {str(hit['fields']['pk'][0]): hit['_score']
+ pks = [hit['_source']['pk'] for hit in hits['hits']['hits']]
+ scores = {str(hit['_source']['pk'][0]): hit['_score']
for hit in hits['hits']['hits']}
# Initialise results dictionary
diff --git a/saleor/search/backends/elasticsearch5.py b/saleor/search/backends/elasticsearch5.py
index 92e7be5351..b1480c3d41 100644
--- a/saleor/search/backends/elasticsearch5.py
+++ b/saleor/search/backends/elasticsearch5.py
@@ -71,7 +71,7 @@ class Elasticsearch5SearchQuery(Elasticsearch2SearchQuery):
class Elasticsearch5SearchResults(Elasticsearch2SearchResults):
- fields_param_name = 'stored_fields'
+ fields_param_name = '_source'
class Elasticsearch5SearchBackend(Elasticsearch2SearchBackend):