{"id":13769787,"url":"https://github.com/algolia/hn-search","last_synced_at":"2025-06-19T15:42:36.388Z","repository":{"id":12002826,"uuid":"14581843","full_name":"algolia/hn-search","owner":"algolia","description":"Hacker News Search","archived":false,"fork":false,"pushed_at":"2023-11-04T05:44:05.000Z","size":104444,"stargazers_count":559,"open_issues_count":29,"forks_count":72,"subscribers_count":91,"default_branch":"master","last_synced_at":"2025-05-11T02:44:21.727Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://hn.algolia.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/algolia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2013-11-21T08:27:17.000Z","updated_at":"2025-05-03T13:03:38.000Z","dependencies_parsed_at":"2024-04-20T07:45:05.257Z","dependency_job_id":null,"html_url":"https://github.com/algolia/hn-search","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/algolia/hn-search","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fhn-search","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fhn-search/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fhn-search/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fhn-search/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/algolia","download_url":"https://codeload.github.com/algolia/hn-search/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/algolia%2Fhn-search/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260781521,"owners_count":23062249,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T17:00:31.552Z","updated_at":"2025-06-19T15:42:31.376Z","avatar_url":"https://github.com/algolia.png","language":"TypeScript","funding_links":[],"categories":["Overview","TypeScript"],"sub_categories":["Hacker News"],"readme":"HN Search powered by Algolia\n==================\n\nThis is the Rails 5 application providing [HN Search](https://hn.algolia.com). It's leveraging [react](https://reactjs.org) on the frontend, [algoliasearch-rails](https://github.com/algolia/algoliasearch-rails) for the search and uses [wkhtmltoimage](https://code.google.com/p/wkhtmltopdf/) to crawl+render thumbnails.\n\nDevelopment/Contributions\n-------------\n\nWe *love* pull-requests :)\n\n### Setup\n\n```sh\n# clone the repository\ngit clone https://github.com/algolia/hn-search\ncd hn-search\n\n# install dependencies\nbundle install\n\n# setup credentials\ncp config/database.example.yml config/database.yml # feel free to edit, default configuration is OK for search-only\ncp config/application.example.yml config/application.yml # feel free to edit, default configuration is OK for search-only\n\n# setup your (sqlite3) database\nbundle exec rake db:migrate\n\n# start contributing enjoying Guard (watchers, livereload, notifications, ...)\nbundle exec guard\n\n# done!\nopen http://localhost:3000\n```\n\n### Code\n\nIf you want to contribute to the UI, the only directory you need to look at is `app/assets`. This directory contains all the JS, HTML \u0026 CSS code.\n\n### Deployment\n\nTo deploy, we're using capistrano and therefore you need SSH access to the underlying machines and run from your own computer:\n\n```shell\nbundle exec cap deploy\n```\n\nThere is currently (December 2018) a bug with `bluepill` stopping the deployment. To workaround it, you need to force a restart with the following command instead:\n\n```shell\nbundle exec cap deploy:restart\n```\n\nThere seems to as well be an issue with thin server, where after deployment orphaned thin processes are not killed. This means that the server tries serving previous version of the app and causes `ChunkLoadErrors` as the manifest points to no longer existing files. To fix the intermittent errors, you need to ssh to both servers, check for any orphaned thin processes and kill them manually.\n\n```shell\nps aux | grep thin\nkill \u003cinsert old thin process pid's\u003e\n```\n\n\nIndexing Configuration\n--------------\n\nThe indexing is configured using the following `algoliasearch` block:\n\n```ruby\nclass Item \u003c ActiveRecord::Base\n  include AlgoliaSearch\n\n  algoliasearch per_environment: true do\n    # the list of attributes sent to Algolia's API\n    attribute :created_at, :title, :url, :author, :points, :story_text, :comment_text, :author, :num_comments, :story_id, :story_title\n    attribute :created_at_i do\n      created_at.to_i\n    end\n\n    # `title` is more important than `{story,comment}_text`, `{story,comment}_text` more than `url`, `url` more than `author`\n    # btw, do not take into account position in most fields to avoid first word match boost\n    attributesToIndex ['unordered(title)', 'unordered(story_text)', 'unordered(comment_text)', 'unordered(url)', 'author', 'created_at_i']\n\n    # list of attributes to highlight\n    attributesToHighlight ['title', 'story_text', 'comment_text', 'url', 'story_url', 'author', 'story_title']\n\n    # tags used for filtering\n    tags do\n      [item_type, \"author_#{author}\", \"story_#{story_id}\"]\n    end\n\n    # use associated number of HN points to sort results (last sort criteria)\n    customRanking ['desc(points)', 'desc(num_comments)']\n\n    # controls the way results are sorted sorting on the following 4 criteria (one after another)\n    # I removed the 'exact' match critera (improve 1-words query relevance, doesn't fit HNSearch needs)\n    ranking ['typo', 'proximity', 'attribute', 'custom']\n\n    # google+, $1.5M raises, C#: we love you\n    separatorsToIndex '+#$'\n  end\n\n  def story_text\n    item_type_cd != Item.comment ? text : nil\n  end\n\n  def story_title\n    comment? \u0026\u0026 story ? story.title : nil\n  end\n\n  def story_url\n    comment? \u0026\u0026 story ? story.url : nil\n  end\n\n  def comment_text\n    comment? ? text : nil\n  end\n\n  def comment?\n    item_type_cd == Item.comment\n  end\nend\n```\n\nCredits\n--------\n* [HackerNews](https://news.ycombinator.com)\n* [Firebase](https://www.firebase.com) for the real-time crawling API\n* [wkhtmltoimage](https://code.google.com/p/wkhtmltopdf/) to back the thumbnails' crawl+rendering\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgolia%2Fhn-search","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falgolia%2Fhn-search","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgolia%2Fhn-search/lists"}