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