Batch Synonyms
editSettings
ACL
$index->saveSynonyms(array synonyms) $index->saveSynonyms(array synonyms), [ // All the following parameters are optional 'forwardToReplicas' => boolean, 'replaceExistingSynonyms' => boolean ])
About this method
Create or update multiple synonyms.
This method enables you to create or update one or more synonyms in a single call.
You can also recreate your entire set of synonyms by using the replaceExistingSynonyms parameter.
Note that each synonym object counts as a single indexing operation.
Examples
Batch synonyms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Batch synonyms,
// with replica forwarding and atomic replacement of existing synonyms
$index->saveSynonyms(
[
[
"objectID" => "a-unique-identifier",
"type" => "synonym",
"synonyms" => ["car", "vehicle", "auto"]
],
[
"objectID" => "another-unique-identifier",
"type" => "synonym",
"synonyms" => ["street", "st"]
]
], [
'forwardToReplicas' => true,
'replaceExistingSynonyms' => true
]
);
Parameters
synonyms
|
type: list
Required
Array of synonym. |
forwardToReplicas
|
type: boolean
default: false
optional
Sends synonyms to all replicas. Without this parameter, or by setting it to false, the method will apply the change only to the specified index. If you want to forward your synonyms to replicas you will need to set this parameter to true. |
replaceExistingSynonyms
|
type: boolean
default: false
optional
Forces the engine to replace all synonyms, using an atomic save. Normally, to replace all synonyms on an index, you would first clear the synonyms,
using clearAllSynonyms, and then create a new list.
However, between the clear and the add, your index will have no synonyms.
This is where By adding this parameter, you do not need to use |
Response
In this section we document the JSON response returned by the API. Each language will encapsulate this response inside objects specific to the language and/or the implementation. So the actual type in your language might differ from what is documented.
JSON format
1
2
3
4
{
"updatedAt":"2013-01-18T15:33:13.556Z",
"taskID": 678
}
updatedAt
|
string
Date at which the indexing job has been created. |
taskID
|
integer
The taskID used with the waitTask method. |