Skip to content

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

Fix problem with elasticsearch5 query

Jakub Draganeka5e4f4c41847
diff --git a/saleor/product/models.py b/saleor/product/models.py
index 5c64a1f36c..133220f51f 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -146,7 +146,8 @@ class Product(models.Model, ItemRange, index.Indexed):
search_fields = [
index.SearchField('name', partial_match=True),
index.SearchField('description'),
- index.FilterField('available_on')]
+ index.FilterField('available_on'),
+ index.FilterField('is_published')]
class Meta:
app_label = 'product'
diff --git a/saleor/search/backends/elasticsearch.py b/saleor/search/backends/elasticsearch.py
index 25229bb468..82207c006a 100644
--- a/saleor/search/backends/elasticsearch.py
+++ b/saleor/search/backends/elasticsearch.py
@@ -220,10 +220,12 @@ class ElasticsearchSearchQuery(BaseSearchQuery):
if lookup == 'exact':
if value is None:
return {
- 'missing': {
- 'field': column_name,
+ 'bool': {
+ 'must_not': {
+ 'field': column_name,
+ }
+ }
}
- }
else:
return {
'term': {
@@ -234,10 +236,12 @@ class ElasticsearchSearchQuery(BaseSearchQuery):
if lookup == 'isnull':
if value:
return {
- 'missing': {
- 'field': column_name,
+ 'bool': {
+ 'must_not': {
+ 'field': column_name,
+ }
+ }
}
- }
else:
return {
'exists': {