forked from pimcore/pimcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrated Elasticsearch 8 and deprecated Elasticsearch 7 integration (…
…pimcore#13410) * integrated pimcore/elasticsearch-client and elasticsearch 8, deprecated elasticsearch 7 * updated docs and phpstan * updated dependencies * added upgrade notes * updated dependencies * phpstan fixes * phpstan fixes * phpstan fixes * phpstan fixes * phpstan fixes * phpstan fixes * phpstan fixes * phpstan fixes * phpstan fixes * phpstan fixes * phpstan fixes * phpstan fixes
- Loading branch information
Showing
12 changed files
with
719 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...EcommerceFrameworkBundle/IndexService/ProductList/ElasticSearch/DefaultElasticSearch8.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\EcommerceFrameworkBundle\IndexService\ProductList\ElasticSearch; | ||
|
||
use Elastic\Elasticsearch\Client; | ||
|
||
class DefaultElasticSearch8 extends AbstractElasticSearch | ||
{ | ||
|
||
/** | ||
* send a request to elasticsearch | ||
* | ||
* @param array $params | ||
* | ||
* @return array | ||
*/ | ||
protected function sendRequest(array $params) | ||
{ | ||
/** | ||
* @var Client $esClient | ||
*/ | ||
$esClient = $this->tenantConfig->getTenantWorker()->getElasticSearchClient(); | ||
$result = []; | ||
|
||
if ($esClient instanceof Client) { | ||
if ($this->doScrollRequest) { | ||
$params = array_merge(['scroll' => $this->scrollRequestKeepAlive], $params); | ||
//kind of dirty hack :/ | ||
$params['body']['size'] = $this->getLimit(); | ||
} | ||
|
||
$result = $esClient->search($params)->asArray(); | ||
|
||
if ($this->doScrollRequest) { | ||
$additionalHits = []; | ||
$scrollId = $result['_scroll_id']; | ||
|
||
while (true) { | ||
$additionalResult = $esClient->scroll(['scroll_id' => $scrollId, 'scroll' => $this->scrollRequestKeepAlive])->asArray(); | ||
|
||
if (count($additionalResult['hits']['hits'])) { | ||
$additionalHits = array_merge($additionalHits, $additionalResult['hits']['hits']); | ||
$scrollId = $additionalResult['_scroll_id']; | ||
} else { | ||
break; | ||
} | ||
} | ||
$result['hits']['hits'] = array_merge($result['hits']['hits'], $additionalHits); | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.