
Ask HN: How does HN's Algolia search by popularity work? - saganus
While trying to find an article via HN&#x27;s Algolia search (and failing at it), I started to do a broader-term search on Stories only, filtering by Popularity and Past Month.<p>I did several searches like this without finding what I wanted until I started scanning results a bit closer and found that sometimes Stories are listed without any order relative to popularity (which I assume is upvote count).<p>For example, searching for just the term &quot;error&quot; with the previous filters, I get the following three results (shown in order of appearance):<p>https:&#x2F;&#x2F;imgur.com&#x2F;GgrH6UK<p>- Elon Musk Teases Second Part of ‘Top Secret Tesla Masterplan’<p><pre><code>  3 points  Errorcod3  8 days ago  2 comments  (https:&#x2F;&#x2F;techcrunch.com&#x2F;2016&#x2F;07&#x2F;11&#x2F;elon-musk-teases-second-part-of-top-secret-tesla-masterplan&#x2F;)
</code></pre>
- Here comes the Pokémon Go malware<p><pre><code>  1 points  Errorcod3  8 days ago  0 comments  (https:&#x2F;&#x2F;techcrunch.com&#x2F;2016&#x2F;07&#x2F;11&#x2F;here-comes-the-pokemon-go-malware&#x2F;)
</code></pre>
- Errol Morris&#x27;s Secret Weapon for Unsettling Interviews: The Interrotron<p><pre><code>  141 points  prawn  8 days ago  42 comments  (http:&#x2F;&#x2F;www.fastcodesign.com&#x2F;1663105&#x2F;errol-morriss-secret-weapon-for-unsettling-interviews-the-interrotron)

</code></pre>
If you look closely, the last story has 141 points, and even though they were all submitted 8 days ago, it shows stories with 3 and 1 points first.<p>So now I am having doubts about how can I trust that the result order is really correct?<p>Is there anything else going on here related to the &quot;Popularity&quot; filter metric? is it maybe something other than upvotes? It just strikes me as very odd that a story that is clearly popular (141 upvotes, 42 comments) is rated lower than stories with 3 and 1 upvotes and 2 and 0 comments respectively.<p>I&#x27;m sure the search engine works fine, so it&#x27;s probably my lack of knowledge on how to fully use it. Are there any guides on how to do good searches on Algolia?
======
e15ctr0n
Looking at your search results for the keyword "error",

[https://hn.algolia.com/?query=error&sort=byPopularity](https://hn.algolia.com/?query=error&sort=byPopularity)

[https://imgur.com/GgrH6UK](https://imgur.com/GgrH6UK)

I can see that you're highlighting search results on Page 3.

The search results for the keyword "error" start on Page 1 with a story that
has 286 points
([https://news.ycombinator.com/item?id=12041210](https://news.ycombinator.com/item?id=12041210))
and end on Page 3 with a story that has just 1 point
([https://news.ycombinator.com/item?id=12072880](https://news.ycombinator.com/item?id=12072880)).

The story on Errol Morris with 141 points
([https://news.ycombinator.com/item?id=12070472](https://news.ycombinator.com/item?id=12070472))
highlights the keyword "Errol" and not "error". This is part of Algolia's
typo-tolerance algorithm.

[https://www.algolia.com/doc/guides/relevance/typo-
tolerance](https://www.algolia.com/doc/guides/relevance/typo-tolerance)

I would recommend that you approach the search with a fresh mind - a good
night's sleep followed by a cup of coffee would probably do it.

------
dzello
Here's a link to information about Algolia's ranking formula -
[https://www.algolia.com/doc/guides/relevance/ranking](https://www.algolia.com/doc/guides/relevance/ranking).
One thing to note is that 'textual relevance' is considered before 'business
relevance'.

One component of textual relevance is the presence of typos. A typo-containing
match (error instead of Errol) carries less weight than a typo-free match, so
it will be ranked lower even when the business relevance ranking (popularity
in likes/comments) is higher.

Algolia is an API so each implementation can be a bit different - developers
have the ability to tune the relevance formula to better suit their needs. So
don't feel bad about needing an explanation, this stuff can get complicated :)

