-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Improvement] Add support for elasticsearch and openSearch (#273)
* add elasticsearch support * Apply php-cs-fixer changes * fix: use factory for service * fix: use opensearch as default * fix: STAN --------- Co-authored-by: lukmzig <[email protected]>
- Loading branch information
Showing
13 changed files
with
290 additions
and
44 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# OpenSearch Client Setup | ||
|
||
:::info | ||
|
||
This bundle requires minimum version of OpenSearch 2.7. | ||
|
||
::: | ||
|
||
Following configuration is required to set up OpenSearch. The OpenSearch client configuration takes place via [Pimcore Opensearch Client](https://github.com/pimcore/opensearch-client) and has two parts: | ||
1) Configuring an OpenSearch client. | ||
2) Define the client to be used by Advanced Object Search bundle. | ||
|
||
```yaml | ||
# Configuring an OpenSearch client | ||
pimcore_open_search_client: | ||
clients: | ||
default: | ||
hosts: ['https://opensearch:9200'] | ||
password: 'admin' | ||
username: 'admin' | ||
ssl_verification: false | ||
|
||
|
||
# Define the client to be used by advanced object search | ||
advanced_object_search: | ||
client_name: default # default is default value here, just need to be specified when other client should be used. | ||
``` | ||
If nothing is configured, a default client connecting to `localhost:9200` is used. | ||
|
||
For the further configuration of the client, please refer to the [Pimcore OpenSearch Client documentation](https://github.com/pimcore/opensearch-client/blob/1.x/doc/02_Configuration.md). |
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,31 @@ | ||
# Elasticsearch Client Setup | ||
|
||
:::info | ||
|
||
This bundle requires minimum version of Elasticsearch 8.0. | ||
|
||
::: | ||
|
||
Following configuration is required to set up Elasticsearch. The Elasticsearch client configuration takes place via [Pimcore Elasticsearch Client](https://github.com/pimcore/elasticsearch-client) and has two parts: | ||
1) Configuring an Elasticsearch client. | ||
2) Define the client to be used by Advanced Object Search bundle. | ||
|
||
```yaml | ||
# Configuring an Elasticsearch client | ||
pimcore_elasticsearch_client: | ||
es_clients: | ||
default: | ||
hosts: ['elastic:9200'] | ||
username: 'elastic' | ||
password: 'somethingsecret' | ||
logger_channel: 'pimcore.elasicsearch' | ||
|
||
# Define the client to be used by advanced object search | ||
advanced_object_search: | ||
client_name: default # default is default value here, just need to be specified when other client should be used. | ||
client_type: 'elasticsearch' # default is 'openSearch' | ||
``` | ||
If nothing is configured, a default client connecting to `localhost:9200` is used. | ||
|
||
For the further configuration of the client, please refer to the [Pimcore Elasticsearch Client documentation](https://github.com/pimcore/elasticsearch-client/blob/1.x/README.md). |
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
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,26 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* 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 AdvancedObjectSearchBundle\Enum; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
enum ClientType: string | ||
{ | ||
case OPEN_SEARCH = 'openSearch'; | ||
case ELASTIC_SEARCH = 'elasticsearch'; | ||
} |
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,78 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* 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 AdvancedObjectSearchBundle\Factory\OpenSearch; | ||
|
||
use AdvancedObjectSearchBundle\Service; | ||
use AdvancedObjectSearchBundle\Tools\IndexConfigService; | ||
use OpenSearch\ClientBuilder; | ||
use Pimcore\Bundle\ElasticsearchClientBundle\SearchClient\ElasticsearchClientInterface; | ||
use Pimcore\Bundle\OpenSearchClientBundle\SearchClient\OpenSearchClientInterface; | ||
use Pimcore\SearchClient\SearchClientInterface; | ||
use Pimcore\Security\User\TokenStorageUserResolver; | ||
use Pimcore\Translation\Translator; | ||
use Psr\Container\ContainerInterface; | ||
use Psr\Log\LoggerInterface; | ||
use RuntimeException; | ||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
|
||
/** | ||
* @internal | ||
* @deprecated will be removed in version 7.0 | ||
*/ | ||
final class LegacyServiceFactory | ||
{ | ||
public function __construct( | ||
private readonly LoggerInterface $logger, | ||
private readonly TokenStorageUserResolver $userResolver, | ||
private readonly EventDispatcherInterface $eventDispatcher, | ||
private readonly Translator $translator, | ||
private readonly IndexConfigService $indexConfigService, | ||
private readonly SearchClientInterface $client | ||
) | ||
{ | ||
|
||
} | ||
|
||
public function create( | ||
ContainerInterface $filterLocator | ||
): Service | ||
{ | ||
$openSearchClient = match (true) { | ||
$this->client instanceof OpenSearchClientInterface => $this->client->getOriginalClient(), | ||
$this->client instanceof ElasticsearchClientInterface => ClientBuilder::create()->build(), | ||
default => null, | ||
}; | ||
|
||
if ($openSearchClient === null) { | ||
throw new RuntimeException('No client found for OpenSearch'); | ||
} | ||
|
||
$service = new Service( | ||
$this->logger, | ||
$this->userResolver, | ||
$filterLocator, | ||
$this->eventDispatcher, | ||
$this->translator, | ||
$this->indexConfigService, | ||
$openSearchClient | ||
); | ||
|
||
$service->setSearchClientInterface($this->client); | ||
|
||
return $service; | ||
} | ||
} |
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.