Set settings

Method signature
$index->setSettings(settings, forwardToReplicas)
Method signature
index.set_settings(settings)
index.set_settings(settings, {forwardToReplicas: true})
Method signature
index.setSettings(settings, callback)
index.setSettings(settings, { forwardToReplicas: forwardToReplicas }, callback)
Method signature
index.set_settings(settings, forwardToReplicas)
Method signature
index.setSettings(
  settings,
  forwardToReplicas: forwardToReplicas,
  completionHandler
)

Method signature
index.setSettingsAsync(settings, forwardToReplicas, null, null)
Method signature
index.SetSettings(settings, forwardToReplicas)
Method signature
index.setSettings(settings, forwardToReplicas)
Method signature
// forwardToReplicas can be passed to the settings map
index.SetSettings(settings)
Method signature
setSettings.of("myIndex").with(settings)
setSettings.of("myIndex").with(settings).and(forwardToReplicas)

About this method

Create or change an index’s settings.

Required API Key ACL: editSettings

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

<?php
$index->setSettings(
  array(
    "customRanking" => array("desc(followers)")
  )
);
index.set_settings(customRanking: ['desc(followers)'])
index.setSettings({'customRanking': ['desc(followers)']}, function(err, content) {
  if (err) throw err;

  console.log(content);
});
index.set_settings({"customRanking": ["desc(followers)"]})
let settings = ["attributesToRetrieve": "name", "birthdate"]
index.setSettings(
  settings,
  forwardToReplicas: false,
  completionHandler: { (content, error) -> Void in
    // [...]
  }
)
boolean forwardToReplicas = false;

index.setSettingsAsync(
  new JSONObject()
    .append("customRanking", "desc(followers)"),
  forwardToReplicas,
  null,
  null
);
bool forwardToReplicas = false;

index.SetSettings(
  JObject.Parse(@"{""customRanking"":[""desc(followers)""]}"),
  forwardToReplicas
);

// Asynchronous
// await index.SetSettingsAsync(
//   JObject.Parse(@"{""customRanking"":[""desc(followers)""]}"),
//   forwardToReplicas
// );
// Sync & Async version

boolean forwardToReplicas = false;

index.setSettings(
  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.
// Updates the settings
settings := algoliasearch.Map{
  "customRanking": []string{"desc(followers)"},
}
res, err := index.SetSettings(settings)
val result: Future[Task] = client.execute {
  changeSettings of "myIndex" `with` IndexSettings(
    customRanking = Some(Seq(
      CustomRanking.asc("att8"),
      CustomRanking.desc("att9")
    ))
  )
}

Set setting and forward to replicas

<?php
$forwardToReplicas = true;

$index->setSettings(
  [
    "searchableAttributes": ["name", "address"]
  ],
  $forwardToReplicas
);
index.set_settings({ customRanking: ['desc(followers)'] }, { forwardToReplicas: true })
index.setSettings({
  'customRanking': ['desc(followers)']
}, {
  forwardToReplicas: true
}, function(err, content) {
  if (err) throw err;

  console.log(content);
});
index.set_settings({"searchableAttributes": ["name", "address"]}, True)
let settings = ["attributesToRetrieve": "name", "birthdate"]
index.setSettings(
  settings,
  forwardToReplicas: true,
  completionHandler: { (content, error) -> Void in
    // [...]
  }
)
JSONObject settings = new JSONObject(
  "{\"attributesToRetrieve\": [\"name\", \"birthdate\"]}"
);

boolean forwardToReplicas = true;
JSONObject setSettingsResult = index.setSettings(
  settings,
  forwardToReplicas,
  null,
  null
);
bool forwardToReplicas = false;

index.SetSettings(
  JObject.Parse(@"{""customRanking"":[""desc(followers)""]}"),
  forwardToReplicas
);

// Asynchronous
// await index.SetSettingsAsync(
//   JObject.Parse(@"{""customRanking"":[""desc(followers)""]}"),
//   forwardToReplicas
// );
//Sync & Async version

boolean forwardToReplicas = false;

index.setSettings(
  new IndexSettings()
    .setCustomRanking(Arrays.asList("desc(followers)")),
  forwardToReplicas
);
settings := algoliasearch.Map{
  "customRanking":   []string{"asc(followers)"},
  "forwardToReplicas": true,
}
res, err := index.SetSettings(settings)
val result: Future[IndexSettings] = client.execute {
  changeSettings of "myIndex" `with` IndexSettings(
    customRanking = Some(Seq(CustomRanking.desc("followers")))
  ) and forwardToReplicas
}

Parameters

settings
type: key value mapping
Required

A mapping of settings parameters you can use on an index.

forwardToReplicas
type: boolean
Optional
default: false

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.

JSON format

{
  "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.

Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala
Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala