userData object lets you store custom data in your index settings.
Usage
- The object must be serializable as JSON.
- You can store up to 32 kB. Larger objects may break your search.
- To access previously stored
userData, use thegetSettingsmethod.
Example
Current API clients
Current API clients
var response = await client.SetSettingsAsync(
"INDEX_NAME",
new IndexSettings
{
UserData = new Dictionary<string, object>
{
{ "extraData", "This is the custom data that you want to store in your index" },
},
}
);
final response = await client.setSettings(
indexName: "INDEX_NAME",
indexSettings: IndexSettings(
userData: {
'extraData':
'This is the custom data that you want to store in your index',
},
),
);
response, err := client.SetSettings(client.NewApiSetSettingsRequest(
"INDEX_NAME",
search.NewEmptyIndexSettings().SetUserData(map[string]any{"extraData": "This is the custom data that you want to store in your index"})))
if err != nil {
// handle the eventual error
panic(err)
}
UpdatedAtResponse response = client.setSettings(
"INDEX_NAME",
new IndexSettings().setUserData(
new HashMap() {
{
put("extraData", "This is the custom data that you want to store in your index");
}
}
)
);
const response = await client.setSettings({
indexName: 'theIndexName',
indexSettings: { userData: { extraData: 'This is the custom data that you want to store in your index' } },
});
var response =
client.setSettings(
indexName = "INDEX_NAME",
indexSettings =
IndexSettings(
userData =
buildJsonObject {
put("extraData", "This is the custom data that you want to store in your index")
}
),
)
$response = $client->setSettings(
'INDEX_NAME',
['userData' => ['extraData' => 'This is the custom data that you want to store in your index'],
],
);
response = client.set_settings(
index_name="INDEX_NAME",
index_settings={
"userData": {
"extraData": "This is the custom data that you want to store in your index"
},
},
)
response = client.set_settings(
"INDEX_NAME",
Algolia::Search::IndexSettings.new(
user_data: {:"extraData" => "This is the custom data that you want to store in your index"}
)
)
val response = Await.result(
client.setSettings(
indexName = "INDEX_NAME",
indexSettings = IndexSettings(
userData = Some(
JObject(
List(
JField("extraData", JString("This is the custom data that you want to store in your index"))
)
)
)
)
),
Duration(100, "sec")
)
let response = try await client.setSettings(
indexName: "INDEX_NAME",
indexSettings: IndexSettings(
userData: ["extraData": "This is the custom data that you want to store in your index"]
)
)
Legacy API clients
Legacy API clients
var extraData = new Object { extraData= "This is the custom data that you want to store in your index"};
IndexSettings settings = new IndexSettings();
settings.UserData = extraData;
index.SetSettings(settings);
userData := opt.UserData(map[string]interface{}{
"extraData": "This is the custom data that you want to sore in your index",
})
res, err := index.SetSettings(search.Settings{
UserData: userData,
})
index.setSettings(
new IndexSettings()
.setUserData( new HashMap() {
{
put("UserDataKey", "This is the custom data that you want to store in your index");
}
});
index
.setSettings({
userData: {
extraData: "This is the custom data that you want to store in your index",
},
})
.then(() => {
// done
});
val settings = settings {
userData = (json { "extraData" to "This is the custom data you want to store in your index"})
}
index.setSettings(settings)
$index->setSettings([
'userData' => [
'extraData' => 'This is the custom data that you want to store in your index',
]
]);
index.set_settings(
{
"userData": {
"extra_data": "This is the custom data that you want to store in your index"
}
}
)
index.set_settings(
{
userData: {
extraData: "This is the custom data that you want to store in your index"
}
}
)
val customData = Some(Map(
"extraData" -> "This is the custom data that you want to store in your index"
))
client.execute {
setSettings of "myIndex" `with` IndexSettings(
userData = customData
)
}
let settings = Settings()
.set(\.userData, to: ["extraData": "This is the custom data you want to store in your index"])
index.setSettings(settings) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}