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