@@ -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 [
0 commit comments