|
12 | 12 | use Magento\Elasticsearch\SearchAdapter\ConnectionManager;
|
13 | 13 | use Magento\Elasticsearch\SearchAdapter\QueryContainerFactory;
|
14 | 14 | use Magento\Elasticsearch\SearchAdapter\ResponseFactory;
|
| 15 | +use Magento\Framework\Phrase; |
15 | 16 | use Magento\Framework\Search\AdapterInterface;
|
| 17 | +use Magento\Framework\Search\Request\EmptyRequestDataException; |
16 | 18 | use Magento\Framework\Search\RequestInterface;
|
17 | 19 | use Magento\Framework\Search\Response\QueryResponse;
|
18 | 20 | use Magento\Search\Model\Search\PageSizeProvider;
|
| 21 | +use OpenSearch\Common\Exceptions\BadRequest400Exception; |
19 | 22 | use OpenSearch\Common\Exceptions\Missing404Exception;
|
20 | 23 | use Psr\Log\LoggerInterface;
|
21 | 24 |
|
@@ -46,23 +49,6 @@ class Adapter implements AdapterInterface
|
46 | 49 | */
|
47 | 50 | private AggregationBuilder $aggregationBuilder;
|
48 | 51 |
|
49 |
| - /** |
50 |
| - * Empty response from OpenSearch |
51 |
| - * |
52 |
| - * @var array |
53 |
| - */ |
54 |
| - private static $emptyRawResponse = [ |
55 |
| - 'hits' => [ |
56 |
| - 'hits' => [] |
57 |
| - ], |
58 |
| - 'aggregations' => [ |
59 |
| - 'price_bucket' => [], |
60 |
| - 'category_bucket' => [ |
61 |
| - 'buckets' => [] |
62 |
| - ] |
63 |
| - ] |
64 |
| - ]; |
65 |
| - |
66 | 52 | /**
|
67 | 53 | * @var QueryContainerFactory
|
68 | 54 | */
|
@@ -144,9 +130,11 @@ public function query(RequestInterface $request) : QueryResponse
|
144 | 130 | }
|
145 | 131 |
|
146 | 132 | $rawResponse = $client->query($query);
|
147 |
| - } catch (Missing404Exception $e) { |
| 133 | + } catch (Missing404Exception|BadRequest400Exception $e) { |
148 | 134 | $this->logger->critical($e);
|
149 |
| - $rawResponse = self::$emptyRawResponse; |
| 135 | + throw new EmptyRequestDataException( |
| 136 | + (new Phrase("Could not perform search query."))->render() |
| 137 | + ); |
150 | 138 | } catch (\Exception $e) {
|
151 | 139 | $this->logger->critical($e);
|
152 | 140 | throw new ClientException($e->getMessage(), $e->getCode(), $e);
|
|
0 commit comments