@@ -371,12 +371,6 @@ public function mergeSettings($indexName, $settings, string $mergeSettingsFrom =
371
371
} catch (Exception $ e ) {
372
372
}
373
373
374
- $ removes = ['slaves ' , 'replicas ' , 'decompoundedAttributes ' , 'synonyms ' ];
375
-
376
- if (isset ($ onlineSettings ['mode ' ]) && $ onlineSettings ['mode ' ] == 'neuralSearch ' ) {
377
- $ removes [] = 'mode ' ;
378
- }
379
-
380
374
if (isset ($ settings ['attributesToIndex ' ])) {
381
375
$ settings ['searchableAttributes ' ] = $ settings ['attributesToIndex ' ];
382
376
unset($ settings ['attributesToIndex ' ]);
@@ -387,7 +381,7 @@ public function mergeSettings($indexName, $settings, string $mergeSettingsFrom =
387
381
unset($ onlineSettings ['attributesToIndex ' ]);
388
382
}
389
383
390
- foreach ($ removes as $ remove ) {
384
+ foreach ($ this -> getSettingsToRemove ( $ onlineSettings ) as $ remove ) {
391
385
if (isset ($ onlineSettings [$ remove ])) {
392
386
unset($ onlineSettings [$ remove ]);
393
387
}
@@ -400,6 +394,34 @@ public function mergeSettings($indexName, $settings, string $mergeSettingsFrom =
400
394
return $ onlineSettings ;
401
395
}
402
396
397
+ /**
398
+ * These settings are to be managed by other processes
399
+ * @param string[] $onlineSettings
400
+ * @return string[]
401
+ */
402
+ protected function getSettingsToRemove (array $ onlineSettings ): array
403
+ {
404
+ $ removals = ['slaves ' , 'replicas ' , 'decompoundedAttributes ' ];
405
+
406
+ if (isset ($ onlineSettings ['mode ' ]) && $ onlineSettings ['mode ' ] == 'neuralSearch ' ) {
407
+ $ removals [] = 'mode ' ;
408
+ }
409
+
410
+ return array_merge ($ removals , $ this ->getSynonymSettingNames ());
411
+ }
412
+
413
+ /**
414
+ * @return string[]
415
+ */
416
+ protected function getSynonymSettingNames (): array
417
+ {
418
+ return [
419
+ 'synonyms ' ,
420
+ 'altCorrections ' ,
421
+ 'placeholders '
422
+ ];
423
+ }
424
+
403
425
/**
404
426
* Legacy function signature to add objects to Algolia
405
427
* @param array $objects
0 commit comments