Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve code purpose clarity and styling
Jakub Draganekaacc576a27fa
diff --git a/saleor/search/backends/newelastic.py b/saleor/search/backends/newelastic.pyindex 1d6c69d089..6a3c78f9e2 100644--- a/saleor/search/backends/newelastic.py+++ b/saleor/search/backends/newelastic.py@@ -5,14 +5,19 @@ from django.utils.six.moves.urllib.parse import urlparsefrom elasticsearch_dsl import Searchfrom elasticsearch_dsl.query import MultiMatch+# module scoped elasticsearch client handler for dependency injectionCLIENT = Elasticsearch()def search_products(phrase):+ ''' Execute external search for product matching phrase '''INDEX = 'storefront__product_product' # TODO: parametrize this+ CONTENT = 'product.Product'query = MultiMatch(fields=['name', 'description'], query=phrase)- search = Search(index=INDEX).query(query).source(['pk']).using(CLIENT)- search = search.filter('match', content_type='product.Product')+ search = (Search(index=INDEX).query(query)+ .source(['pk'])+ .using(CLIENT)+ .filter('match', content_type=CONTENT))return [hit.pk for hit in search.execute()]diff --git a/saleor/search/backends/test_newelastic.py b/saleor/search/backends/test_newelastic.pyindex 80dc19d590..ce78591226 100644--- a/saleor/search/backends/test_newelastic.py+++ b/saleor/search/backends/test_newelastic.py@@ -11,7 +11,7 @@ def search_phrase():@pytest.fixturedef es_search_query(search_phrase):- query = {+ return {'query': {'bool': {'must': [{@@ -29,7 +29,6 @@ def es_search_query(search_phrase):},'_source': ['pk']}- return query@pytest.fixture