Usage
- Attribute names are case-sensitive.
objectIDis always retrieved, even when not specified.- Use
*to include all attributes. - Use
-attributeName(combined with*) to exclude specific attributes. This can be useful if you want to hide sensitive data—for example, if you don’t want to expose your custom ranking attributes. - Attributes listed in
unretrievableAttributesare never retrieved unless the request is authenticated with the Admin API key. - Nested attributes are supported. For example,
author.namereturns:{"author": {"name": "Agatha Christie"}}.
There’s no hard limit on the number of attributes you can include,
but adding too many can slow down
getSettings operations
and degrade performance in the Algolia dashboard.Examples
Set default list of retrievable attributes
Current API clients
Current API clients
var response = await client.SetSettingsAsync(
"INDEX_NAME",
new IndexSettings
{
AttributesToRetrieve = new List<string> { "author", "title", "content" },
}
);
final response = await client.setSettings(
indexName: "INDEX_NAME",
indexSettings: IndexSettings(
attributesToRetrieve: [
"author",
"title",
"content",
],
),
);
response, err := client.SetSettings(client.NewApiSetSettingsRequest(
"INDEX_NAME",
search.NewEmptyIndexSettings().SetAttributesToRetrieve(
[]string{"author", "title", "content"})))
if err != nil {
// handle the eventual error
panic(err)
}
UpdatedAtResponse response = client.setSettings(
"INDEX_NAME",
new IndexSettings().setAttributesToRetrieve(Arrays.asList("author", "title", "content"))
);
const response = await client.setSettings({
indexName: 'theIndexName',
indexSettings: { attributesToRetrieve: ['author', 'title', 'content'] },
});
var response =
client.setSettings(
indexName = "INDEX_NAME",
indexSettings = IndexSettings(attributesToRetrieve = listOf("author", "title", "content")),
)
$response = $client->setSettings(
'INDEX_NAME',
['attributesToRetrieve' => [
'author',
'title',
'content',
],
],
);
response = client.set_settings(
index_name="INDEX_NAME",
index_settings={
"attributesToRetrieve": [
"author",
"title",
"content",
],
},
)
response = client.set_settings(
"INDEX_NAME",
Algolia::Search::IndexSettings.new(attributes_to_retrieve: ["author", "title", "content"])
)
val response = Await.result(
client.setSettings(
indexName = "INDEX_NAME",
indexSettings = IndexSettings(
attributesToRetrieve = Some(Seq("author", "title", "content"))
)
),
Duration(100, "sec")
)
let response = try await client.setSettings(
indexName: "INDEX_NAME",
indexSettings: IndexSettings(attributesToRetrieve: ["author", "title", "content"])
)
Legacy API clients
Legacy API clients
IndexSettings settings = new IndexSettings
{
AttributesToRetrieve = new List { "author", "title", "content" }
};
res, err := index.SetSettings(search.Settings{
AttributesToRetrieve: opt.AttributesToRetrieve(
"author",
"title",
"content",
),
})
index.setSettings(
new IndexSettings().setAttributesToRetrieve(Arrays.asList(
"author",
"title",
"content"
))
);
index.setSettings({
attributesToRetrieve: ["author", "title", "content"],
});
val settings = settings {
attributesToRetrieve {
+"author"
+"title"
+"content"
}
}
index.setSettings(settings)
$index->setSettings([
'attributesToRetrieve' => [
'author',
'title',
'content'
]
]);
index.set_settings({"attributesToRetrieve": ["author", "title", "content"]})
index.set_settings(
{
attributesToRetrieve: [
"author",
"title",
"content"
]
}
)
client.execute {
setSettings of "myIndex" `with` IndexSettings(
attributesToRetrieve = Some(Seq(
"author",
"title",
"content"
))
)
}
let settings = Settings()
.set(\.attributesToRetrieve, to: [
"author",
"title",
"content"
])
index.setSettings(settings) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}
Make all attributes retrievable by default
Current API clients
Current API clients
var response = await client.SetSettingsAsync(
"INDEX_NAME",
new IndexSettings { AttributesToRetrieve = new List<string> { "*" } }
);
final response = await client.setSettings(
indexName: "INDEX_NAME",
indexSettings: IndexSettings(
attributesToRetrieve: [
"*",
],
),
);
response, err := client.SetSettings(client.NewApiSetSettingsRequest(
"INDEX_NAME",
search.NewEmptyIndexSettings().SetAttributesToRetrieve(
[]string{"*"})))
if err != nil {
// handle the eventual error
panic(err)
}
UpdatedAtResponse response = client.setSettings("INDEX_NAME", new IndexSettings().setAttributesToRetrieve(Arrays.asList("*")));
const response = await client.setSettings({
indexName: 'theIndexName',
indexSettings: { attributesToRetrieve: ['*'] },
});
var response =
client.setSettings(
indexName = "INDEX_NAME",
indexSettings = IndexSettings(attributesToRetrieve = listOf("*")),
)
$response = $client->setSettings(
'INDEX_NAME',
['attributesToRetrieve' => [
'*',
],
],
);
response = client.set_settings(
index_name="INDEX_NAME",
index_settings={
"attributesToRetrieve": [
"*",
],
},
)
response = client.set_settings("INDEX_NAME", Algolia::Search::IndexSettings.new(attributes_to_retrieve: ["*"]))
val response = Await.result(
client.setSettings(
indexName = "INDEX_NAME",
indexSettings = IndexSettings(
attributesToRetrieve = Some(Seq("*"))
)
),
Duration(100, "sec")
)
let response = try await client.setSettings(
indexName: "INDEX_NAME",
indexSettings: IndexSettings(attributesToRetrieve: ["*"])
)
Legacy API clients
Legacy API clients
IndexSettings settings = new IndexSettings
{
AttributesToRetrieve = new List { "*" }
};
res, err := index.SetSettings(search.Settings{
AttributesToRetrieve: opt.AttributesToRetrieve(
"*",
),
})
index.setSettings(
new IndexSettings().setAttributesToRetrieve(Collections.singletonList(
"*"
))
);
index
.setSettings({
attributesToRetrieve: ["*"],
})
.then(() => {
// done
});
val settings = settings {
attributesToRetrieve { +"*" }
}
index.setSettings(settings)
$index->setSettings([
'attributesToRetrieve' => [
"*"
]
]);
index.set_settings({"attributesToRetrieve": ["*"]})
index.set_settings(
{
attributesToRetrieve: [
"*"
]
}
)
client.execute {
setSettings of "myIndex" `with` IndexSettings(
replaceSynonymsInHighlight = Some(false)
)
}
let settings = Settings()
.set(\.attributesToRetrieve, to: ["*"])
index.setSettings(settings) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}
Override default list of retrievable attributes for the current search
Current API clients
Current API clients
var response = await client.SearchSingleIndexAsync<Hit>(
"INDEX_NAME",
new SearchParams(
new SearchParamsObject
{
Query = "query",
AttributesToRetrieve = new List<string> { "title", "content" },
}
)
);
final response = await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchParamsObject(
query: "query",
attributesToRetrieve: [
"title",
"content",
],
),
);
response, err := client.SearchSingleIndex(client.NewApiSearchSingleIndexRequest(
"INDEX_NAME").WithSearchParams(search.SearchParamsObjectAsSearchParams(
search.NewEmptySearchParamsObject().SetQuery("query").SetAttributesToRetrieve(
[]string{"title", "content"}))))
if err != nil {
// handle the eventual error
panic(err)
}
SearchResponse response = client.searchSingleIndex(
"INDEX_NAME",
new SearchParamsObject().setQuery("query").setAttributesToRetrieve(Arrays.asList("title", "content")),
Hit.class
);
const response = await client.searchSingleIndex({
indexName: 'indexName',
searchParams: { query: 'query', attributesToRetrieve: ['title', 'content'] },
});
var response =
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams =
SearchParamsObject(query = "query", attributesToRetrieve = listOf("title", "content")),
)
$response = $client->searchSingleIndex(
'INDEX_NAME',
['query' => 'query',
'attributesToRetrieve' => [
'title',
'content',
],
],
);
response = client.search_single_index(
index_name="INDEX_NAME",
search_params={
"query": "query",
"attributesToRetrieve": [
"title",
"content",
],
},
)
response = client.search_single_index(
"INDEX_NAME",
Algolia::Search::SearchParamsObject.new(query: "query", attributes_to_retrieve: ["title", "content"])
)
val response = Await.result(
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams = Some(
SearchParamsObject(
query = Some("query"),
attributesToRetrieve = Some(Seq("title", "content"))
)
)
),
Duration(100, "sec")
)
let response: SearchResponse<Hit> = try await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchSearchParams.searchSearchParamsObject(SearchSearchParamsObject(
query: "query",
attributesToRetrieve: ["title", "content"]
))
)
Legacy API clients
Legacy API clients
index.Search(new Query("query")
{
AttributesToRetrieve = new List{ "title", "content" }
});
res, err := index.Search("query", search.Settings{
AttributesToRetrieve: opt.AttributesToRetrieve(
"title",
"content",
),
})
index.search(
new Query("query").setAttributesToRetrieve(Arrays.asList(
"title",
"content"
))
);
index
.search("query", {
attributesToRetrieve: ["title", "content"],
})
.then(({ hits }) => {
console.log(hits);
});
val query = query("query") {
attributesToRetrieve {
+"title"
+"content"
}
}
index.search(query)
$results = $index->search('query', [
'attributesToRetrieve' => [
'title',
'content'
]
]);
results = index.search("query", {"attributesToRetrieve": ["title", "content"]})
results = index.search(
"query",
{
attributesToRetrieve: [
"title",
"content"
]
}
)
client.execute {
search into "myIndex" query Query(
query = Some("query"),
attributesToRetrieve = Some(Seq(
"title",
"content"
))
)
}
let query = Query("query")
.set(\.attributesToRetrieve, to: [
"title",
"content"
])
index.search(query: query) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}
Specify some attributes not to retrieve
Retrieve all attributes of an item except for its SKU and internal description.Current API clients
Current API clients
var response = await client.SetSettingsAsync(
"INDEX_NAME",
new IndexSettings
{
AttributesToRetrieve = new List<string> { "*", "-SKU", "-internal_desc" },
}
);
final response = await client.setSettings(
indexName: "INDEX_NAME",
indexSettings: IndexSettings(
attributesToRetrieve: [
"*",
"-SKU",
"-internal_desc",
],
),
);
response, err := client.SetSettings(client.NewApiSetSettingsRequest(
"INDEX_NAME",
search.NewEmptyIndexSettings().SetAttributesToRetrieve(
[]string{"*", "-SKU", "-internal_desc"})))
if err != nil {
// handle the eventual error
panic(err)
}
UpdatedAtResponse response = client.setSettings(
"INDEX_NAME",
new IndexSettings().setAttributesToRetrieve(Arrays.asList("*", "-SKU", "-internal_desc"))
);
const response = await client.setSettings({
indexName: 'theIndexName',
indexSettings: { attributesToRetrieve: ['*', '-SKU', '-internal_desc'] },
});
var response =
client.setSettings(
indexName = "INDEX_NAME",
indexSettings = IndexSettings(attributesToRetrieve = listOf("*", "-SKU", "-internal_desc")),
)
$response = $client->setSettings(
'INDEX_NAME',
['attributesToRetrieve' => [
'*',
'-SKU',
'-internal_desc',
],
],
);
response = client.set_settings(
index_name="INDEX_NAME",
index_settings={
"attributesToRetrieve": [
"*",
"-SKU",
"-internal_desc",
],
},
)
response = client.set_settings(
"INDEX_NAME",
Algolia::Search::IndexSettings.new(attributes_to_retrieve: ["*", "-SKU", "-internal_desc"])
)
val response = Await.result(
client.setSettings(
indexName = "INDEX_NAME",
indexSettings = IndexSettings(
attributesToRetrieve = Some(Seq("*", "-SKU", "-internal_desc"))
)
),
Duration(100, "sec")
)
let response = try await client.setSettings(
indexName: "INDEX_NAME",
indexSettings: IndexSettings(attributesToRetrieve: ["*", "-SKU", "-internal_desc"])
)
Legacy API clients
Legacy API clients
IndexSettings settings = new IndexSettings
{
AttributesToRetrieve = new List { "*", "-SKU", "-internal_desc" }
};
res, err := index.SetSettings(search.Settings{
AttributesToRetrieve: opt.AttributesToRetrieve(
"*",
"-SKU",
"-internal_desc",
),
})
index.setSettings(
new IndexSettings().setAttributesToRetrieve(Arrays.asList(
"*",
"-SKU",
"-internal_desc"
))
);
index
.setSettings({
attributesToRetrieve: ["*", "-SKU", "-internal_desc"],
})
.then(() => {
// done
});
val settings = settings {
attributesToRetrieve {
+"sku"
+"internal_desc"
excludeAttributes = true
}
}
index.setSettings(settings)
$index->setSettings([
'attributesToRetrieve' => [
'*',
'-SKU',
'-internal_desc'
]
]);
index.set_settings({"attributesToRetrieve": ["*", "-SKU", "-internal_desc"]})
index.set_settings(
{
attributesToRetrieve: [
"*",
"-SKU",
"-internal_desc"
]
}
)
client.execute {
setSettings of "myIndex" `with` IndexSettings(
attributesToRetrieve = Some(Seq(
"*",
"-SKU",
"-internal_desc"
))
)
}
let settings = Settings()
.set(\.attributesToRetrieve, to: [
"*",
"-SKU",
"-internal_desc"
])
index.setSettings(settings) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}