This version of the JavaScript API client has been deprecated in favor of the latest version of the JavaScript API client.
Required API Key: any key with the editSettings
ACL
About this method
Create or change an index’s settings.
Only specified settings are overridden; unspecified settings are left unchanged.
Specifying null
for a setting resets it to its default value.
The supported settings are listed in the Settings Parameters page.
Performance wise, it’s better to set settings
before pushing the data.
Examples
Simple set settings
1
2
3
4
5
| $index->setSettings(
[
'customRanking' => ['desc(followers)']
]
);
|
1
| index.set_settings(customRanking: ['desc(followers)'])
|
1
2
3
4
5
| index.setSettings({'customRanking': ['desc(followers)']}, (err, content) => {
if (err) throw err;
console.log(content);
});
|
1
| index.set_settings({'customRanking': ['desc(followers)']})
|
1
2
3
4
5
6
7
| let settings = ["attributesToRetrieve": "name", "birthdate"]
index.setSettings(
settings,
completionHandler: { (content, error) -> Void in
// [...]
}
)
|
1
2
3
4
|
index.setSettingsAsync(
new JSONObject().put("customRanking", "desc(followers)")
);
|
1
2
3
4
5
6
7
8
9
| IndexSettings settings = new IndexSettings
{
CustomRanking = new List<string> { "desc(followers)" }
};
index.SetSettings(setting);
// Asynchronous
await index.SetSettingsAsync(settings);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| boolean forwardToReplicas = false;
// Sync version
index.setSettings(
new IndexSettings()
.setCustomRanking(Collections.singletonList("desc(followers)")),
forwardToReplicas
);
// Async version
index.setSettingsAsync(
new IndexSettings()
.setCustomRanking(Collections.singletonList("desc(followers)")),
forwardToReplicas
);
// To add a custom setting for an index,
// extend the class `IndexSettings` and add your getter/setter.
// The new settings will be automatically serialized by jackson.
|
1
2
3
4
| settings := search.Settings{
CustomRanking: opt.CustomRanking("desc(followers)"),
}
res, err := index.SetSettings(settings)
|
1
2
3
4
5
6
7
8
| val result: Future[Task] = client.execute {
changeSettings of "myIndex" `with` IndexSettings(
customRanking = Some(Seq(
CustomRanking.asc("att8"),
CustomRanking.desc("att9")
))
)
}
|
1
2
3
4
5
6
7
8
9
10
11
| val settings = settings {
searchableAttributes {
+"name"
+"address"
}
customRanking {
+Desc("followers")
}
}
index.setSettings(settings)
|
Set setting and forward to replicas
1
2
3
4
5
6
7
8
9
10
11
| $forwardToReplicas = true;
$index->setSettings(
[
'searchableAttributes' => ['name', 'address'],
'customRanking' => ['desc(followers)'],
],
[
'forwardToReplicas' => $forwardToReplicas
]
);
|
1
2
3
4
| index.set_settings(
{ customRanking: ['desc(followers)'] },
{ forwardToReplicas: true }
)
|
1
2
3
4
5
6
7
8
9
| index.setSettings({
'customRanking': ['desc(followers)']
}, {
forwardToReplicas: true
}, (err, content) => {
if (err) throw err;
console.log(content);
});
|
1
2
3
| index.set_settings({'searchableAttributes': ['name', 'address']}, {
'forwardToReplicas': True
})
|
1
2
3
4
5
6
7
8
| let settings = ["attributesToRetrieve": "name", "birthdate"]
index.setSettings(
settings,
forwardToReplicas: true,
completionHandler: { (content, error) -> Void in
// [...]
}
)
|
1
2
3
4
5
6
7
8
9
10
11
| JSONObject settings = new JSONObject(
"{\"attributesToRetrieve\": [\"name\", \"birthdate\"]}"
);
boolean forwardToReplicas = true;
JSONObject setSettingsResult = index.setSettings(
settings,
forwardToReplicas,
null,
null
);
|
1
2
3
4
5
6
7
8
9
10
| IndexSettings settings = new IndexSettings
{
SearchableAttributes = new List<string> { "name", "adress" },
CustomRanking = new List<string> { "desc(followers)" }
};
index.SetSettings(settings, forwardToReplicas: true);
// Asynchronous
await index.SetSettingsAsync(settings, forwardToReplicas: true);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| boolean forwardToReplicas = false;
// Sync version
index.setSettings(
new IndexSettings()
.setCustomRanking(Arrays.asList("desc(followers)"))
forwardToReplicas
);
// Async version
index.setSettingsAsync(
new IndexSettings()
.setCustomRanking(Arrays.asList("desc(followers)")),
forwardToReplicas
);
|
1
2
3
4
| settings := search.Settings{
CustomRanking: opt.CustomRanking("asc(followers)"),
}
res, err := index.SetSettings(settings, opt.ForwardToReplicas(true))
|
1
2
3
4
5
6
7
| val result: Future[IndexSettings] = client.execute {
changeSettings of "myIndex" `with` IndexSettings(
customRanking = Some(Seq(CustomRanking.desc("followers"))),
forwardToReplicas = Some(forwardToReplicas.`true`)
)
}
|
1
2
3
4
5
6
7
8
9
10
11
| val settings = settings {
searchableAttributes {
+"name"
+"address"
}
customRanking {
+Desc("followers")
}
}
index.setSettings(settings, forwardToReplicas = true)
|
Parameters
settings
|
type: key value mapping
Required
A mapping of settings parameters
you can use on an index.
|
forwardToReplicas
|
type: boolean
default: false
Optional
Whether to forward the same settings to the replica indices.
|
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.
1
2
3
4
| {
"updatedAt":"2013-01-18T15:33:13.556Z",
"taskID": 678
}
|
updatedAt
|
Date at which the indexing job has been created.
|
taskID
|
The taskID used with the waitTask method.
|