Skip to content

Commit 6803ef6

Browse files
committed
Settings upgrade in ReIndex Command
1 parent d21ae9a commit 6803ef6

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
All notable changes to this `laravel-elasticsearch` package will be documented in this file.
44

5+
## v5.5.2 - 2026-03-16
6+
7+
### Improved
8+
9+
- `elastic:re-index` mapping analysis now includes settings for analyzers, tokenizers, char filters, filters, and normalizers.
10+
11+
**Full Changelog**: https://github.com/pdphilip/laravel-elasticsearch/compare/v5.5.1...v5.5.2
12+
513
## v5.5.1 - 2026-03-16
614

715
### Added

src/Commands/ReIndexCommand.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -682,16 +682,28 @@ private function showMappings(string $index): void
682682

683683
private function mappingAnalysis(): array
684684
{
685-
$currentMapping = $this->schema->getMappings($this->indexName);
686-
$desiredMapping = Sanitizer::flattenMappingProperties([
687-
'properties' => $this->schema->compileMapping($this->mappingDefinition),
688-
]);
685+
$desired = $this->schema->compileMapping($this->mappingDefinition);
689686

690-
$currentFlat = collect($currentMapping)->dot();
691-
$desiredFlat = collect($desiredMapping)->dot();
687+
$currentMappings = $this->schema->getMappings($this->indexName);
688+
$desiredMappings = Sanitizer::flattenMappingProperties($desired['mappings'] ?? []);
692689

693-
$changedMappings = $currentFlat->diffAssoc($desiredFlat);
694-
$newMappings = $desiredFlat->diffAssoc($currentFlat);
690+
$currentSettings = $this->schema->getSettings($this->indexName);
691+
$currentAnalysis = $currentSettings[$this->connection->getIndexPrefix().$this->indexName]['settings']['index']['analysis'] ?? [];
692+
$desiredAnalysis = $desired['settings']['analysis'] ?? [];
693+
694+
$currentBody = ['properties' => $currentMappings];
695+
$desiredBody = ['properties' => $desiredMappings];
696+
697+
if (! empty($currentAnalysis) || ! empty($desiredAnalysis)) {
698+
$currentBody['settings']['analysis'] = $currentAnalysis;
699+
$desiredBody['settings']['analysis'] = $desiredAnalysis;
700+
}
701+
702+
$current = collect($currentBody)->dot();
703+
$desired = collect($desiredBody)->dot();
704+
705+
$changedMappings = $current->diffAssoc($desired);
706+
$newMappings = $desired->diffAssoc($current);
695707
$hasChanges = $changedMappings->count() || $newMappings->count();
696708

697709
return [

src/Schema/Grammars/Grammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function compileUpdate(Blueprint $blueprint, Fluent $command, Connection
7272

7373
public function compileMapping(Blueprint $blueprint): array
7474
{
75-
return $this->getColumns($blueprint);
75+
return $this->buildBody($blueprint);
7676
}
7777

7878
protected function buildBody(Blueprint $blueprint): array

0 commit comments

Comments
 (0)