getRankingInfo parameter adds a _rankingInfo object to each result (hit) in the search response.
This object contains detailed metadata about how Algolia ranked the result, including scores from ranking criteria.
_rankingInfo
Object with details about ranking of each result.
Show child attributes
Show child attributes
integer
Number of typos for this match.
integer
Encodes both the attribute index (position in
searchableAttributes) and the word position.
Divide the number by 1,000 to get the attribute index; the remainder gives the word position.
Used only for attributes set to "ordered" in searchableAttributes.For example, if firstMatchedWord is 2,001: the best-matching attribute is the second attribute in the list,
and the first matched word is the second word within that attribute (both 0-based).For more details, see Understanding word position.integer
Sum of distances between matched query words.
integer
Internal custom ranking score for the record.
(Reserved for internal use by Algolia).
integer
Number of words that matched exactly.
If
alternativesAsExact is not empty,
it includes matches with plurals or synonyms.integer
Number of matched query words, including prefix and typo-tolerant matches.
integer
Filter scores.
For more information, see Optional filters’ scoring
boolean
True if the result was promoted by a rule.
Absent otherwise.
integer
Distance from the query’s location to the matched record’s location, divided by the precision.
integer
Precision for calculating distances, in meters.
All distances are multiples of this setting.
object
Details about the matched geographic point, including coordinates and distance.
lat and lng are Algolia’s internal values, not the original _geoloc on the record. Returned values may show fewer decimals than the values you indexed. For background, see Geographical ranking precision.object
Information about how Personalization influenced this result (if enabled).
string
Internal name of the server that processed the request.
string
Index name used for the query.
This may differ in A/B tests.
string
ID of the A/B test if applicable.
integer
Variant ID (position in the list of variants) used in the A/B test. Starts from 1.
string
Normalized query string after stop word removal
and advanced syntax processing.
boolean
True if facet counts were approximated due to a timeout.
boolean
True if the engine did not retrieve all results due to a timeout.
list<string>
List of index rule IDs applied to the query.
Example
Current API clients
Current API clients
var response = await client.SearchSingleIndexAsync<Hit>(
"INDEX_NAME",
new SearchParams(new SearchParamsObject { Query = "test", GetRankingInfo = true })
);
final response = await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchParamsObject(
query: "test",
getRankingInfo: true,
),
);
response, err := client.SearchSingleIndex(client.NewApiSearchSingleIndexRequest(
"INDEX_NAME").WithSearchParams(search.SearchParamsObjectAsSearchParams(
search.NewEmptySearchParamsObject().SetQuery("test").SetGetRankingInfo(true))))
if err != nil {
// handle the eventual error
panic(err)
}
SearchResponse response = client.searchSingleIndex(
"INDEX_NAME",
new SearchParamsObject().setQuery("test").setGetRankingInfo(true),
Hit.class
);
const response = await client.searchSingleIndex({
indexName: 'indexName',
searchParams: { query: 'test', getRankingInfo: true },
});
var response =
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams = SearchParamsObject(query = "test", getRankingInfo = true),
)
$response = $client->searchSingleIndex(
'INDEX_NAME',
['query' => 'test',
'getRankingInfo' => true,
],
);
response = client.search_single_index(
index_name="INDEX_NAME",
search_params={
"query": "test",
"getRankingInfo": True,
},
)
response = client.search_single_index(
"INDEX_NAME",
Algolia::Search::SearchParamsObject.new(query: "test", get_ranking_info: true)
)
val response = Await.result(
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams = Some(
SearchParamsObject(
query = Some("test"),
getRankingInfo = Some(true)
)
)
),
Duration(100, "sec")
)
let response: SearchResponse<Hit> = try await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchSearchParams.searchSearchParamsObject(SearchSearchParamsObject(
query: "test",
getRankingInfo: true
))
)
Legacy API clients
Legacy API clients
index.search(
new Query("query")
.GetRankingInfo(true)
);
res, err := index.Search(
"query",
opt.GetRankingInfo(true),
)
index.search(
new Query("query")
.setGetRankingInfo(true)
);
index
.search("query", {
getRankingInfo: true,
})
.then(({ hits }) => {
console.log(hits.map((hit) => hit._rankingInfo));
});
val query = query("query") {
getRankingInfo = true
}
index.search(query)
$results = $index->search('query', [
'getRankingInfo' => true
]);
//foreach ($results['hits'] as $hit) {
// var_dump($hit['_rankingInfo']);
//}
results = index.search("query", {"getRankingInfo": True})
# for hit in results['hits']:
# print(hit['_rankingInfo'])
results = index.search(
"query",
{
getRankingInfo: true
}
)
# results['hits'].each do |hit|
# puts hit['_rankingInfo']
# end
client.execute {
search into "myIndex" query Query(
query = Some("query"),
getRankingInfo = Some(true)
)
}
let query = Query("query")
.set(\.getRankingInfo, to: true)
index.search(query: query) { result in
if case .success(let response) = result {
print("Response: \(response)")
}
}