Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

rank.js 641 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  1. // This module accepts an Algolia search record object as input and
  2. // returns a ranking score which influences how results are sorted.
  3. // higher in this list == higher search ranking
  4. // anything NOT matched by this list gets the highest ranking
  5. // a lower ranking means the record will have a higher priority
  6. const rankings = [
  7. '/rest',
  8. '/graphql',
  9. '/site-policy'
  10. ].reverse()
  11. module.exports = function rank (record) {
  12. for (const index in rankings) {
  13. const pattern = rankings[index]
  14. if (record.url.includes(pattern)) return Number(index)
  15. }
  16. // Set the default ranking to the highest possible
  17. return rankings.length
  18. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...