Skip to content

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

Make user search broader

Jakub Draganek409f05b243f1
diff --git a/saleor/search/backends/elasticsearch_dashboard.py b/saleor/search/backends/elasticsearch_dashboard.py
index 7aaa601b17..7a5c56cae9 100644
--- a/saleor/search/backends/elasticsearch_dashboard.py
+++ b/saleor/search/backends/elasticsearch_dashboard.py
@@ -10,7 +10,12 @@ def _search_products(phrase):
def _search_users(phrase):
- return UserDocument.search().query('match', user=phrase).source(False)
+ user_query = MultiMatch(
+ fields=['user', 'email'],
+ query=phrase,
+ type='cross_fields',
+ operator='and')
+ return UserDocument.search().query(user_query).source(False)
def _search_orders(phrase):
diff --git a/saleor/search/backends/test_dashboard.py b/saleor/search/backends/test_dashboard.py
index a6895f51ad..a8cf1ea586 100644
--- a/saleor/search/backends/test_dashboard.py
+++ b/saleor/search/backends/test_dashboard.py
@@ -1,7 +1,6 @@
from __future__ import unicode_literals
from . import elasticsearch_dashboard
-
PHRASE = 'You can go to the west'
PRODUCT_QUERY = {
'_source': False,
@@ -24,8 +23,11 @@ ORDERS_QUERY = {
USERS_QUERY = {
'_source': False,
'query': {
- 'match': {
- 'user': PHRASE
+ 'multi_match': {
+ 'fields': ['user', 'email'],
+ 'operator': 'and',
+ 'query': PHRASE,
+ 'type': 'cross_fields'
}
}
}