Troubleshooting relevance
On this page
Try these strategies to troubleshoot any relevance issue:
- Get ranking information with the
getRankingInfo
parameter. This parameter lets you look at and analyze the criteria Algolia uses to rank results. For a given query it returns the value for each ranking criteria. By understanding those values you can understand why a result appears before or after another. See more below. - Reproducing a problem on a small dataset and solving it by process of elimination. This strategy can be used alongside the
getRankingInfo
parameter. It helps you improve the results of specific queries. The idea is to create a very small index that mirrors your main index, and to test different configurations one-by-one until you’ve singled out the problem or inefficiency. - Analytics and Insights. This lets you follow your users’ behavior with Analytics.
The engine’s ranking decisions
You can find out why a record is ranked the way it is, and use this information to troubleshoot your data and relevance settings. You can do this in the Algolia dashboard or with the API.
Troubleshooting in the dashboard
If you go to your dashboard and search, you have a “Ranking Info” section that details how Algolia ranked this record.
If you look at the second hit, you’ll have the difference between this object and the one preceding it.
Troubleshoot with the API
Ranking information can be retrieved with the API.
For that, you need to use the parameter getRankingInfo
and set it to true.
Initialize the client
Set up an API client and send your data to Algolia.
Search with getRankingInfo
1
2
3
4
5
6
7
$results = $index->search('query', [
'getRankingInfo' => true
]);
//foreach ($results['hits'] as $hit) {
// var_dump($hit['_rankingInfo']);
//}
This gives you ranking info
Take a look at the following results in the _rankingInfo
attribute:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"_rankingInfo": {
"nbTypos": 0,
"firstMatchedWord": 0,
"proximityDistance": 0,
"userScore": 7,
"geoDistance": 1600,
"geoPrecision": 1,
"nbExactWords": 0,
"words": 0,
"filters": 0,
"matchedGeoLocation": {
"lat": 37.3688,
"lng": -122.036,
"distance": 1600
}
}
}