This repository was archived by the owner on Jul 31, 2018. It is now read-only.
File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -173,9 +173,18 @@ public function _setSettings($setToTmpIndices = false)
173
173
if (isset ($ settings ['synonyms ' ])) {
174
174
$ index ->batchSynonyms ($ settings ['synonyms ' ], true , true );
175
175
}
176
+ else {
177
+ // If no synonyms are passed, clear all synonyms from index
178
+ $ index ->clearSynonyms (true );
179
+ }
176
180
177
181
if (count (array_keys ($ settings )) > 0 ) {
178
- $ index ->setSettings ($ settings );
182
+ // Synonyms cannot be pushed into "setSettings", it's got rejected from API and throwing exception
183
+ // Synonyms cannot be removed directly from $settings var, because then synonym would not be set to other indices
184
+ $ settingsWithoutSynonyms = $ settings ;
185
+ unset($ settingsWithoutSynonyms ['synonyms ' ]);
186
+
187
+ $ index ->setSettings ($ settingsWithoutSynonyms );
179
188
}
180
189
181
190
if ($ b && isset ($ settings ['slaves ' ])) {
@@ -189,6 +198,7 @@ public function _setSettings($setToTmpIndices = false)
189
198
$ index = $ modelHelper ->getIndices ($ this , $ slave )[0 ];
190
199
191
200
$ s = array_merge ($ settings , $ slaves_settings [$ slave ]);
201
+ unset($ s ['synonyms ' ]);
192
202
193
203
if (count (array_keys ($ s )) > 0 )
194
204
$ index ->setSettings ($ s );
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ public function testSetSettings()
70
70
$ index = Mockery::mock ('\AlgoliaSearch\Index ' );
71
71
$ index ->shouldReceive ('setSettings ' )->with (['slaves ' => ['model_6_desc_testing ' ]]);
72
72
$ index ->shouldReceive ('setSettings ' )->with (['ranking ' => ['desc(name) ' ]]);
73
+ $ index ->shouldReceive ('clearSynonyms ' );
73
74
74
75
/** @var \AlgoliaSearch\Laravel\ModelHelper $realModelHelper */
75
76
$ realModelHelper = App::make ('\AlgoliaSearch\Laravel\ModelHelper ' );
You can’t perform that action at this time.
0 commit comments