File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
app/code/Magento/Elasticsearch/Elasticsearch5/SearchAdapter Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -76,13 +76,27 @@ public function query(RequestInterface $request)
76
76
{
77
77
$ client = $ this ->connectionManager ->getConnection ();
78
78
$ aggregationBuilder = $ this ->aggregationBuilder ;
79
-
80
79
$ query = $ this ->mapper ->buildQuery ($ request );
81
80
$ aggregationBuilder ->setQuery ($ this ->queryContainerFactory ->create (['query ' => $ query ]));
82
- $ rawResponse = $ client ->query ($ query );
83
-
81
+ if ($ client ->indexExists ($ query ['index ' ])) {
82
+ $ rawResponse = $ client ->query ($ query );
83
+ } else {
84
+ $ rawResponse = [
85
+ "hits " =>
86
+ [
87
+ "hits " => []
88
+ ],
89
+ "aggregations " =>
90
+ [
91
+ "price_bucket " => [],
92
+ "category_bucket " =>
93
+ [
94
+ "buckets " => []
95
+ ]
96
+ ]
97
+ ];
98
+ }
84
99
$ rawDocuments = isset ($ rawResponse ['hits ' ]['hits ' ]) ? $ rawResponse ['hits ' ]['hits ' ] : [];
85
-
86
100
$ queryResponse = $ this ->responseFactory ->create (
87
101
[
88
102
'documents ' => $ rawDocuments ,
You can’t perform that action at this time.
0 commit comments