Commit 1584fa37 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Elasticsearch (reindex)

 - Augmentation de la taille du BULK
 - Désactivation des replicats
 - Suppression de l'autorefresh lors de la création des index
parent 5ec72489
Loading
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -78,6 +78,11 @@ abstract class ElasticSearchEngine
    protected function indicesCreateBody(): array
    {
        return [
            'settings' => [
                'number_of_shards' => 1,
                'number_of_replicas' => 0,  // Désactive les réplicas en local
                'refresh_interval' => '-1', // Désactive le refresh pendant le bulk
            ],
            'mappings' => [
                // Suppression de la détection des dates/nombres
                'date_detection' => false,
@@ -137,6 +142,7 @@ abstract class ElasticSearchEngine
        $client = $this->getClient();

        try {
            $params = ['body' => []];
            $i = 0;
            foreach ($items as $item) {
                $i++;
@@ -151,7 +157,7 @@ abstract class ElasticSearchEngine
                $params['body'][] = $dt;

                // On envoie par paquet de 1000
                if ($i % 500 == 0) {
                if ($i % 2000 == 0) {
                    $this->loggerService->debug(" + BULK (" . count($params['body']) . ") ");
                    $responses = $this->getClient()->bulk($params);

@@ -165,6 +171,8 @@ abstract class ElasticSearchEngine
                $this->loggerService->debug(" + BULK FINAL (" . count($params['body']) . ") ");
                $client->bulk($params);
            }
            $client->indices()->refresh(['index' => $this->getIndex()]); //

            $this->loggerService->debug(" = $i item(s) indexed ");
        } catch (\Exception $exception) {
            $msg = "Réindexation impossible";
+3 −0
Original line number Diff line number Diff line
@@ -113,6 +113,9 @@ class MapperElasticSearch
    public function getMappingAnalysis()
    {
        return [
            'number_of_shards' => 1,
            'number_of_replicas' => 0,  // Désactivation des réplicas
            'refresh_interval' => '-1', // Désactivation du refresh
            'analysis' => [
                'tokenizer' => [
                    // Considérer les _ comme des séparateurs
+2 −10
Original line number Diff line number Diff line
@@ -203,17 +203,9 @@ class OrganizationElasticSearch extends ElasticSearchEngine implements IOrganiza
        ];
    }
    protected function indicesCreateBody(): array {
        $mapper = new MapperElasticSearch();
        return [
            'settings' => [
                'analysis' => [
                    'analyzer' => [
                        'folding_analyzer' => [
                            'tokenizer' => 'standard',
                            'filter' => ['lowercase', 'asciifolding']
                        ]
                    ]
                ]
            ],
            'settings' => $mapper->getMappingAnalysis(),
            'mappings' => [
                'properties' => [
                    'id' => ['type' => 'keyword'],
+2 −10
Original line number Diff line number Diff line
@@ -40,17 +40,9 @@ class PersonElasticSearch extends ElasticSearchEngine implements IPersonISearchS

    protected function indicesCreateBody(): array
    {
        $mapper = new MapperElasticSearch();
        return [
            'settings' => [
                'analysis' => [
                    'analyzer' => [
                        'folding_analyzer' => [
                            'tokenizer' => 'standard',
                            'filter' => ['lowercase', 'asciifolding']
                        ]
                    ]
                ]
            ],
            'settings' => $mapper->getMappingAnalysis(),
            'mappings' => [
                'properties' => [
                    'id' => ['type' => 'keyword'],