Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
elasticsearch now can have a different index setting per environment
- Loading branch information
1 parent
82ccc12
commit 169860b
Showing
11 changed files
with
115 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
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
34 changes: 34 additions & 0 deletions
34
packages/framework/src/Component/Elasticsearch/IndexDefinitionModifier.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,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Component\Elasticsearch; | ||
|
||
use Shopsys\FrameworkBundle\Component\Environment\EnvironmentType; | ||
|
||
class IndexDefinitionModifier | ||
{ | ||
/** | ||
* @param string $environment | ||
* @param bool $forceElasticLimit | ||
*/ | ||
public function __construct( | ||
protected readonly string $environment, | ||
protected readonly bool $forceElasticLimit, | ||
) { | ||
} | ||
|
||
/** | ||
* @param array $decodedDefinition | ||
* @return array | ||
*/ | ||
public function modifyDefinition(array $decodedDefinition): array | ||
{ | ||
if ($this->environment !== EnvironmentType::PRODUCTION || $this->forceElasticLimit) { | ||
$decodedDefinition['settings']['index']['number_of_shards'] = 1; | ||
$decodedDefinition['settings']['index']['number_of_replicas'] = 0; | ||
} | ||
|
||
return $decodedDefinition; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -67,3 +67,5 @@ PACKETERY_SENDER='shopsys_test' | |
SENTRY_DSN= | ||
SENTRY_ENVIRONMENT= | ||
SENTRY_RELEASE= | ||
|
||
FORCE_ELASTIC_LIMITS=false |
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