{"id":21421891,"url":"https://github.com/rlancer/algoliarethinkdb","last_synced_at":"2025-08-18T19:04:11.451Z","repository":{"id":77230340,"uuid":"71211415","full_name":"rlancer/AlgoliaRethinkDB","owner":"rlancer","description":"A demo app on how to use Algolia with RethinkDB change feeds.","archived":false,"fork":false,"pushed_at":"2016-11-19T00:43:12.000Z","size":1843,"stargazers_count":28,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-14T09:11:49.995Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rlancer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2016-10-18T05:15:52.000Z","updated_at":"2017-12-13T05:11:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"8839d2e9-47e5-43c7-8cff-08dff86a8e5b","html_url":"https://github.com/rlancer/AlgoliaRethinkDB","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rlancer/AlgoliaRethinkDB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlancer%2FAlgoliaRethinkDB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlancer%2FAlgoliaRethinkDB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlancer%2FAlgoliaRethinkDB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlancer%2FAlgoliaRethinkDB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rlancer","download_url":"https://codeload.github.com/rlancer/AlgoliaRethinkDB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rlancer%2FAlgoliaRethinkDB/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271043504,"owners_count":24689767,"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","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-22T20:40:20.688Z","updated_at":"2025-08-18T19:04:11.315Z","avatar_url":"https://github.com/rlancer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[RethinkDB](https://www.rethinkdb.com) + [Algolia](https://www.algolia.com) \n=================\n\nUsing realtime change feeds to make indexing a breeze! \n------------------------------------------------------\n\nAt [Collaborizm](https://www.collaborizm.com) we use search all over our app. \n\nInitially we used pure ReQL to power our search features, but as we grew, this became problematic as RethinkDB does not support proper indexing for search. \nAfter evaluating a few technologies, we went with Algolia. Luckily, implementing Algolia with RethinkDB was a breeze. \n\nThis guide should provide the basic structure needed to hook up Algolia with RethinkDB. \nLeveraging realtime change feeds enables you to forget about wiring up all the places where data is changed in your app. \nInstead, you simply let the change feed tell you when data is changed and you send it over to Algolia.       \n\n### Running the code\n*Requires [Node.js](https://nodejs.org) v4.x or higher*\n\n\n**From the terminal** \n```bash  \n $ git clone git@github.com:rlancer/AlgoliaRethinkDB.git\n $ cd AlgoliaRethinkDB\n # Edit config.js with your api keys from Algolia \n $ vim config.js \n $ rethinkdb\n $ npm i\n $ npm run dev\n```\nIf that all worked visit [http://localhost:3006](http://localhost:3006) to launch the UI\n\nYou should see\n \n\u003cimg width=\"903\" alt=\"screen shot 2016-10-22 at 1 18 25 am\" src=\"https://cloud.githubusercontent.com/assets/1339007/19617127/e1852ee0-97f5-11e6-9b53-ff47c5e27ef6.png\"\u003e\n\nClick to add 100 random names to the DB, have the node console open to see the changefeed in action.\n\nClick a search result to inspect it / delete it, have the node console open to see the changefeed handle deletes.\n\n### Important parts of the code\n```javascript\nimport rethinkdbdash from 'rethinkdbdash';\nimport algoliasearch from 'algoliasearch';\nimport config from './config';\n\n// RethinkDB client, using rethinkdbdash for async await\nconst r = rethinkdbdash({db: 'algolia'});\n\n// Algolia client\nconst algolia = algoliasearch(config.applicationId, config.adminApiKey);\n\n// Create `users` index\nconst userIndex = algolia.initIndex('users');\n\n// Sets the attributes to index\nuserIndex.setSettings({attributesToIndex: ['first', 'last']}).then();\n\n(async()=\u003e {\n  // Create database `algolia` if it doesn't exist\n  await r.dbList().contains('algolia').branch(true, r.dbCreate('algolia'));\n\n  // Create table `users` if it doesn't exist\n  await r.tableList().contains('users').branch(true, r.tableCreate('users'));\n\n  // Listen to changes on tabale `users`\n  (await r.table('users').changes()).each(async(err, item)=\u003e {\n    const {new_val, old_val} = item;\n    if (new_val) {\n      // Add changed values to the `users` index\n      const resp = await userIndex.addObject({objectID: new_val.id, ...new_val});\n      console.log('Added', new_val, '\\nTo the `users` index', resp);\n    }\n  });\n})();\n```\n\n\n# Special considerations \n\nSince it's impossible to ensure that an update is properly indexed 100% of the time, it's important to provide a mechanism to resync any data that might have failed to sync via the changefeed.\n\nIn our app we do this via a Cron, which syncs recently modified data. This does lead to multi Algolia operations per an update, but it's the only reliable way to insure that data is properly synced even in edge case failure scenarios. \n\nBe sure to not to reindex too much data too frequently or else it could eat into your Algolia operations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frlancer%2Falgoliarethinkdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frlancer%2Falgoliarethinkdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frlancer%2Falgoliarethinkdb/lists"}