MongoDB: implementing Hacker News ranking algorithm [closed]
Hacker News's article ranking algorithm, as described by its creator, and further elaborated on here, is:
(p - 1) / (t + 2) ^ 1.5
– where:
p
is the article's voted score
t
is its age in hours
It then ranks articles on the front page using this formula. It's clearly possible to implement this in SQL, but what about MongoDB? If possible, a detailed explanation of how to achieve this sorting algorithm would be great, as well as a code sample.
Thanks so much.
database mongodb sorting ranking hacker-news
closed as too broad by Samuel Liew♦ Nov 15 '18 at 1:15
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
Hacker News's article ranking algorithm, as described by its creator, and further elaborated on here, is:
(p - 1) / (t + 2) ^ 1.5
– where:
p
is the article's voted score
t
is its age in hours
It then ranks articles on the front page using this formula. It's clearly possible to implement this in SQL, but what about MongoDB? If possible, a detailed explanation of how to achieve this sorting algorithm would be great, as well as a code sample.
Thanks so much.
database mongodb sorting ranking hacker-news
closed as too broad by Samuel Liew♦ Nov 15 '18 at 1:15
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
Hacker News's article ranking algorithm, as described by its creator, and further elaborated on here, is:
(p - 1) / (t + 2) ^ 1.5
– where:
p
is the article's voted score
t
is its age in hours
It then ranks articles on the front page using this formula. It's clearly possible to implement this in SQL, but what about MongoDB? If possible, a detailed explanation of how to achieve this sorting algorithm would be great, as well as a code sample.
Thanks so much.
database mongodb sorting ranking hacker-news
Hacker News's article ranking algorithm, as described by its creator, and further elaborated on here, is:
(p - 1) / (t + 2) ^ 1.5
– where:
p
is the article's voted score
t
is its age in hours
It then ranks articles on the front page using this formula. It's clearly possible to implement this in SQL, but what about MongoDB? If possible, a detailed explanation of how to achieve this sorting algorithm would be great, as well as a code sample.
Thanks so much.
database mongodb sorting ranking hacker-news
database mongodb sorting ranking hacker-news
asked Aug 16 '18 at 2:11
Luke Fisk-LennonLuke Fisk-Lennon
8461833
8461833
closed as too broad by Samuel Liew♦ Nov 15 '18 at 1:15
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as too broad by Samuel Liew♦ Nov 15 '18 at 1:15
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I think this article provides a great explanation for what you need. It contains a detailed explanation on how to implement a ranking algorithm (inspired specifically by the HackerNews algorithm) using MongoDB, and even contains relevant code snippets.
Basically, the author of the algorithm implemented ranking directly as a part of the MongoDB query, which can be done for simple ranking algorithms using MongoDB operators on other columns. This is completely analogous to the SQL implementation in the answer you cited.
A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.
– Suraj Rao
Nov 14 '18 at 16:10
@SurajRao Fair enough, I thought the title of the article was indicative enough in this particular case because it deals exactly with what OP was asking for. Quoting the most relevant part of an article isn't exactly feasible here since OP was asking for a detailed explanation, not a brief answer. If you think providing context for the link isn't enough I'll delete my answer, even though I truly think it can help whoever is interested in this question.
– Dean Gurvitz
Nov 14 '18 at 16:35
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think this article provides a great explanation for what you need. It contains a detailed explanation on how to implement a ranking algorithm (inspired specifically by the HackerNews algorithm) using MongoDB, and even contains relevant code snippets.
Basically, the author of the algorithm implemented ranking directly as a part of the MongoDB query, which can be done for simple ranking algorithms using MongoDB operators on other columns. This is completely analogous to the SQL implementation in the answer you cited.
A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.
– Suraj Rao
Nov 14 '18 at 16:10
@SurajRao Fair enough, I thought the title of the article was indicative enough in this particular case because it deals exactly with what OP was asking for. Quoting the most relevant part of an article isn't exactly feasible here since OP was asking for a detailed explanation, not a brief answer. If you think providing context for the link isn't enough I'll delete my answer, even though I truly think it can help whoever is interested in this question.
– Dean Gurvitz
Nov 14 '18 at 16:35
add a comment |
I think this article provides a great explanation for what you need. It contains a detailed explanation on how to implement a ranking algorithm (inspired specifically by the HackerNews algorithm) using MongoDB, and even contains relevant code snippets.
Basically, the author of the algorithm implemented ranking directly as a part of the MongoDB query, which can be done for simple ranking algorithms using MongoDB operators on other columns. This is completely analogous to the SQL implementation in the answer you cited.
A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.
– Suraj Rao
Nov 14 '18 at 16:10
@SurajRao Fair enough, I thought the title of the article was indicative enough in this particular case because it deals exactly with what OP was asking for. Quoting the most relevant part of an article isn't exactly feasible here since OP was asking for a detailed explanation, not a brief answer. If you think providing context for the link isn't enough I'll delete my answer, even though I truly think it can help whoever is interested in this question.
– Dean Gurvitz
Nov 14 '18 at 16:35
add a comment |
I think this article provides a great explanation for what you need. It contains a detailed explanation on how to implement a ranking algorithm (inspired specifically by the HackerNews algorithm) using MongoDB, and even contains relevant code snippets.
Basically, the author of the algorithm implemented ranking directly as a part of the MongoDB query, which can be done for simple ranking algorithms using MongoDB operators on other columns. This is completely analogous to the SQL implementation in the answer you cited.
I think this article provides a great explanation for what you need. It contains a detailed explanation on how to implement a ranking algorithm (inspired specifically by the HackerNews algorithm) using MongoDB, and even contains relevant code snippets.
Basically, the author of the algorithm implemented ranking directly as a part of the MongoDB query, which can be done for simple ranking algorithms using MongoDB operators on other columns. This is completely analogous to the SQL implementation in the answer you cited.
edited Nov 14 '18 at 16:42
answered Nov 14 '18 at 16:07
Dean GurvitzDean Gurvitz
188111
188111
A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.
– Suraj Rao
Nov 14 '18 at 16:10
@SurajRao Fair enough, I thought the title of the article was indicative enough in this particular case because it deals exactly with what OP was asking for. Quoting the most relevant part of an article isn't exactly feasible here since OP was asking for a detailed explanation, not a brief answer. If you think providing context for the link isn't enough I'll delete my answer, even though I truly think it can help whoever is interested in this question.
– Dean Gurvitz
Nov 14 '18 at 16:35
add a comment |
A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.
– Suraj Rao
Nov 14 '18 at 16:10
@SurajRao Fair enough, I thought the title of the article was indicative enough in this particular case because it deals exactly with what OP was asking for. Quoting the most relevant part of an article isn't exactly feasible here since OP was asking for a detailed explanation, not a brief answer. If you think providing context for the link isn't enough I'll delete my answer, even though I truly think it can help whoever is interested in this question.
– Dean Gurvitz
Nov 14 '18 at 16:35
A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.
– Suraj Rao
Nov 14 '18 at 16:10
A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.
– Suraj Rao
Nov 14 '18 at 16:10
@SurajRao Fair enough, I thought the title of the article was indicative enough in this particular case because it deals exactly with what OP was asking for. Quoting the most relevant part of an article isn't exactly feasible here since OP was asking for a detailed explanation, not a brief answer. If you think providing context for the link isn't enough I'll delete my answer, even though I truly think it can help whoever is interested in this question.
– Dean Gurvitz
Nov 14 '18 at 16:35
@SurajRao Fair enough, I thought the title of the article was indicative enough in this particular case because it deals exactly with what OP was asking for. Quoting the most relevant part of an article isn't exactly feasible here since OP was asking for a detailed explanation, not a brief answer. If you think providing context for the link isn't enough I'll delete my answer, even though I truly think it can help whoever is interested in this question.
– Dean Gurvitz
Nov 14 '18 at 16:35
add a comment |