{"id":22489733,"url":"https://github.com/ssbc/ssb-search2","last_synced_at":"2025-08-02T22:31:05.635Z","repository":{"id":42393493,"uuid":"388165434","full_name":"ssbc/ssb-search2","owner":"ssbc","description":"Full-text search in SSB using ssb-db2","archived":false,"fork":false,"pushed_at":"2024-01-24T22:08:52.000Z","size":54,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-22T17:20:48.211Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ssbc.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}},"created_at":"2021-07-21T15:39:26.000Z","updated_at":"2022-05-16T09:00:44.000Z","dependencies_parsed_at":"2024-01-24T18:29:29.651Z","dependency_job_id":"de75e45a-5efb-400b-bb1d-496965be0d91","html_url":"https://github.com/ssbc/ssb-search2","commit_stats":null,"previous_names":["staltz/ssb-search2"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-search2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-search2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-search2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-search2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssbc","download_url":"https://codeload.github.com/ssbc/ssb-search2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228184375,"owners_count":17881767,"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-12-06T17:20:33.248Z","updated_at":"2024-12-06T17:22:58.938Z","avatar_url":"https://github.com/ssbc.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# ssb-search2\n\n\u003e An SSB secret-stack plugin for **full-text search** using ssb-db2\n\nThis is a similar to [ssb-search](https://github.com/ssbc/ssb-search), built with ssb-db2. The differences with ssb-search are:\n\n- Supports only `ssb-db2`\n- Supports Unicode, i.e. can search for \"Smörgås\" or Chinese\n- ssb-search ignores small words (2 characters long, e.g. \"to\", \"of\"), which hurts the search for terms like \"EU\" or \"VR\" as well as Chinese words with one character, but ssb-search2 ignores only lowercase ASCII letters of length 1 or 2, which means it can index \"VR\" and \"EU\" and Chinese\n\n## Install\n\n```\nnpm install ssb-search2\n```\n\n## Usage\n\n- Requires **Node.js 12** or higher\n- Requires `secret-stack@^6.2.0`\n- Requires `ssb-db2@\u003e=3.4.0`\n\n```diff\n SecretStack({appKey: require('ssb-caps').shs})\n   .use(require('ssb-master'))\n+  .use(require('ssb-db2'))\n+  .use(require('ssb-search2'))\n   .use(require('ssb-conn'))\n   .use(require('ssb-blobs'))\n   .call(null, config)\n```\n\nNow, just pluck the ssb-db2 operator at `ssb.search2.operator` and use it like this:\n\n```js\n// Pluck the operator and name it whatever you want, e.g. `containsWords`\nconst containsWords = sbot.search2.operator;\n\nsbot.db.query(\n  where(containsWords('secure scuttlebutt')),\n  toCallback((err, msgs) =\u003e {\n    console.log(msgs) // all messages containing \"secure\" and \"scuttlebutt\"\n                      // somewhere inside `msg.value.content.text`\n  })\n),\n```\n\n\"But I get wrong results! I get messages that have 'secure' somewhere and 'scuttlebutt' somewhere else, while in reality I really want 'secure scuttlebutt' together!\"\n\nNo problem! Just add a post-processing step that ensures the exact expression is together:\n\n```js\npull(\n  sbot.db.query(\n    where(containsWords('secure scuttlebutt')),\n    toPullStream()\n  ),\n  pull.filter((msg) =\u003e\n    msg.value.content.text.toLowerCase().includes('secure scuttlebutt'),\n  ),\n  pull.collect((err, msgs) =\u003e {\n    console.log(msgs); // all messages containing exactly the expression\n                       // \"secure scuttlebutt\" inside `msg.value.content.text`\n  }),\n);\n```\n\n## License\n\nLGPL-3.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssbc%2Fssb-search2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssbc%2Fssb-search2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssbc%2Fssb-search2/lists"}