Api reference icon

Set settings

Set settings

Description Set one or more settings of an index.
PHP Ruby JS Python iOS Android C# Java Go Scala name setSettings() setSettings() set_settings() set_settings() setSettings() SetSettings() setSettings() setSettingsAsync() SetSettings() setSettings() changeSettings()
Required ACL

editSettings

More details

With this method, you can set an index’s settings. Doing so will impact all ensuing searches.

For a list and description of all settings, go to the Settings API Parameters page.

Performance wise, it’s better to do a Set settings before pushing the data.

By default doing a Set settings on an index will not forward the call to the replicas. Forwarding settings updates to the replicas of an index can be done using the forwardToReplicas option.

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) {
  if (!err) {
    console.log('success');
  }
});
index.set_settings({"customRanking": ["desc(followers)"]})
let customRanking = ["desc(followers)", "asc(name)"]
let settings = ["customRanking": customRanking]
index.setSettings(settings)
index.setSettingsAsync(new JSONObject().append("customRanking", "desc(followers)"), null);
index.SetSettings(JObject.Parse(@"{""customRanking"":[""desc(followers)""]}"));
// Asynchronous
await index.SetSettingsAsync(JObject.Parse(@"{""customRanking"":[""desc(followers)""]}"));
// Sync & Async version

index.setSettings(new IndexSettings().setCustomRanking(Collections.singletonList("desc(followers)")));

// 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(
    searchableAttributes = Some(Seq(SearchableAttributes.attribute("att1"), SearchableAttributes.attributes("att2", "att3"), SearchableAttributes.unordered("att4"))),
    numericAttributesForFiltering = Some(Seq(NumericAttributesForFiltering.equalOnly("att5"))),
    ranking = Some(Seq(
      Ranking.typo,
      Ranking.geo,
      Ranking.words,
      Ranking.proximity,
      Ranking.attribute,
      Ranking.exact,
      Ranking.custom,
      Ranking.asc("att6"),
      Ranking.desc("att7")
    )),
    customRanking = Some(Seq(
      CustomRanking.asc("att8"),
      CustomRanking.desc("att9")
    )),
    synonyms = Some(Seq(Seq("black", "dark"), Seq("small", "little", "mini"))),
    placeholders = Some(Map("<streetnumber>" -> Seq("1", "2", "3", "4", "5"))),
    altCorrections = Some(Seq(AltCorrection("foot", "feet", 1))),
    typoTolerance = Some(TypoTolerance.strict)
  )
}

Set setting and forward to replicas

<?php
$index->setSettings(['customRanking' => ['desc(followers)']], true);
index.set_settings({"customRanking" => ["desc(followers)"]}, {"forwardToReplicas" => true})
index.setSettings({'customRanking': ['desc(followers)']}, {forwardToReplicas: true}, function(err) {
  if (!err) {
    console.log('success');
  }
});
index.set_settings({"customRanking": ["desc(followers)"]}, True)
let settings = ["attributesToRetrieve": "name", "birthdate"]
index.setSettings(settings, forwardToReplicas: true, completionHandler: { (content, error) -> Void in
    // [...]
})
JSONObject settings = new JSONObject("{\"attributesToRetrieve\": [\"name\", \"birthdate\"]}");
JSONObject setSettingsResult = index.setSettings(settings, true);
index.waitTask(setSettingsResult.getString("taskID"));
index.SetSettings(JObject.Parse(@"{""customRanking"":[""desc(followers)""]}"), true);
// Asynchronous
await index.SetSettingsAsync(JObject.Parse(@"{""customRanking"":[""desc(followers)""]}"), true);
//Sync & Async version

index.setSettings(new IndexSettings().setCustomRanking(Arrays.asList("desc(followers)")), true);
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
}