Swift

Settings

Get settings - getSettings

You can retrieve settings:

index.getSettings(completionHandler: { (content, error) -> Void in
    if error == nil
        print("Settings: \(content!)")
    }
})

Set settings - setSettings

let customRanking = ["desc(followers)", "asc(name)"]
let settings = ["customRanking": customRanking]
index.setSettings(settings)

You can find the list of parameters you can set in the Settings Parameters section

Warning

Performance wise, it’s better to do a setSettings before pushing the data

Replica settings

You can forward all settings updates to the replicas of an index by using the forwardToReplicas option:

let settings = ["attributesToRetrieve": "name", "birthdate"]
index.setSettings(settings, forwardToReplicas: true, completionHandler: { (content, error) -> Void in
    // [...]
})

Index settings parameters

Here is the list of parameters you can use with the set settings method (settings scope).

Parameters that can be overridden at search time also have the search scope.

Attributes

Ranking

Filtering / Faceting

Highlighting / Snippeting

Pagination

Typos

Query Strategy

Performance

Advanced