{"_id":"@albertsyh/orama","name":"@albertsyh/orama","dist-tags":{"latest":"3.0.5"},"versions":{"3.0.5":{"name":"@albertsyh/orama","version":"3.0.5","type":"module","description":"A complete search engine and RAG pipeline in your browser, server, or edge network with support for full-text, vector, and hybrid search in less than 2kb.","sideEffects":false,"main":"./dist/commonjs/index.js","exports":{"./package.json":"./package.json",".":{"deno":{"types":"./dist/deno/index.d.ts","default":"./dist/deno/index.js"},"browser":{"types":"./dist/browser/index.d.ts","default":"./dist/browser/index.js"},"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./internals":{"deno":{"types":"./dist/deno/internals.d.ts","default":"./dist/deno/internals.js"},"browser":{"types":"./dist/browser/internals.d.ts","default":"./dist/browser/internals.js"},"import":{"types":"./dist/esm/internals.d.ts","default":"./dist/esm/internals.js"},"require":{"types":"./dist/commonjs/internals.d.ts","default":"./dist/commonjs/internals.js"}},"./components":{"deno":{"types":"./dist/deno/components.d.ts","default":"./dist/deno/components.js"},"browser":{"types":"./dist/browser/components.d.ts","default":"./dist/browser/components.js"},"import":{"types":"./dist/esm/components.d.ts","default":"./dist/esm/components.js"},"require":{"types":"./dist/commonjs/components.d.ts","default":"./dist/commonjs/components.js"}},"./trees":{"deno":{"types":"./dist/deno/trees.d.ts","default":"./dist/deno/trees.js"},"browser":{"types":"./dist/browser/trees.d.ts","default":"./dist/browser/trees.js"},"import":{"types":"./dist/esm/trees.d.ts","default":"./dist/esm/trees.js"},"require":{"types":"./dist/commonjs/trees.d.ts","default":"./dist/commonjs/trees.js"}}},"types":"./dist/commonjs/index.d.ts","repository":{"type":"git","url":"git+https://github.com/albertsyh/orama.git"},"bugs":{"url":"https://github.com/albertsyh/orama"},"keywords":["full-text search","vector search","vector database","vectors","search","fuzzy search","typo-tolerant search","full-text"],"author":{"name":"Michele Riva","email":"michele.riva@orama.com","url":"https://github.com/MicheleRiva"},"contributors":[{"name":"Tommaso Allevi","email":"tommaso.allevi@orama.com","url":"https://github.com/allevo"},{"name":"Paolo Insogna","email":"paolo.insogna@oramasearch.com","url":"http://cowtech.it"}],"license":"Apache-2.0","devDependencies":{"@oramacloud/client":"1.3.14","@playwright/test":"^1.29.2","@swc/cli":"^0.1.59","@swc/core":"^1.3.27","@types/node":"^20.9.0","@types/tap":"^15.0.7","auto-changelog":"^2.4.0","c8":"^7.12.0","commitizen":"^4.2.6","glob":"^9.2.3","prettier":"^2.8.1","tap":"^21.0.1","tap-mocha-reporter":"^5.0.3","tape":"^5.6.1","tcompare":"^6.0.0","tsd":"^0.29.0","tshy":"^3.0.2","tsx":"^3.12.1","typescript":"^5.0.0","@orama/stemmers":"3.0.5","@orama/stopwords":"3.0.5"},"engines":{"node":">= 16.0.0"},"tap":{"extends":"tests/config/tap.yml"},"tshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts","./internals":"./src/internals.ts","./components":"./src/components.ts","./trees":"./src/trees.ts"},"esmDialects":["deno","browser"]},"module":"./dist/esm/index.js","scripts":{"benchmark":"node ../../benchmarks/index.js","predev":"rm -rf dist && mkdir dist","dev":"swc -s -w --extensions .ts,.cts -d dist src","prebuild":"npm run lint","build":"tshy","lint":"exit 0;","test":"c8 -c tests/config/c8-local.json tap tests/*.test.ts","test:ci":"c8 -c tests/config/c8-ci.json tap --no-color tests/*.test.ts","test:smoke":"tap tests/smoke/*.test.ts","test:types":"tsc --emitDeclarationOnly; tsd --files tests/type/","ci":"npm run build && npm run test:ci && npm run test:types"},"homepage":"https://github.com/albertsyh/orama#readme","_id":"@albertsyh/orama@3.0.5","_integrity":"sha512-2VRx1R3uUr1R8bx81lXBOkZzbBBAhIPcY/5l9duGXTm/eeshlJo/f7r74wKzOoyKF/X5U6ZYPBCVwGidCIR2wg==","_resolved":"/private/var/folders/lj/gs4p1s995xqg1kz__qcd1m_80000gn/T/c93d6555a326433bdff2c22c83b7e788/albertsyh-orama-3.0.5.tgz","_from":"file:albertsyh-orama-3.0.5.tgz","_nodeVersion":"20.4.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-2VRx1R3uUr1R8bx81lXBOkZzbBBAhIPcY/5l9duGXTm/eeshlJo/f7r74wKzOoyKF/X5U6ZYPBCVwGidCIR2wg==","shasum":"b619be1440fd01dc44010a75f8b82483196aa548","tarball":"https://registry.npmjs.org/@albertsyh/orama/-/orama-3.0.5.tgz","fileCount":523,"unpackedSize":1949916,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICy8wJJ5ISsdgURHxVMA+EjNOt1QRx1F8Rw/K8wD0SBkAiEAmRFO4roiy8d13fUxqIDXDawYWg214lqJJcinUFYNaok="}]},"_npmUser":{"name":"albertsyh","email":"albert@synomus.io"},"directories":{},"maintainers":[{"name":"albertsyh","email":"albert@synomus.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/orama_3.0.5_1739066472098_0.7335411949639361"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-09T02:01:11.966Z","3.0.5":"2025-02-09T02:01:12.438Z","modified":"2025-02-09T02:01:12.814Z"},"maintainers":[{"name":"albertsyh","email":"albert@synomus.io"}],"description":"A complete search engine and RAG pipeline in your browser, server, or edge network with support for full-text, vector, and hybrid search in less than 2kb.","homepage":"https://github.com/albertsyh/orama#readme","keywords":["full-text search","vector search","vector database","vectors","search","fuzzy search","typo-tolerant search","full-text"],"repository":{"type":"git","url":"git+https://github.com/albertsyh/orama.git"},"contributors":[{"name":"Tommaso Allevi","email":"tommaso.allevi@orama.com","url":"https://github.com/allevo"},{"name":"Paolo Insogna","email":"paolo.insogna@oramasearch.com","url":"http://cowtech.it"}],"author":{"name":"Michele Riva","email":"michele.riva@orama.com","url":"https://github.com/MicheleRiva"},"bugs":{"url":"https://github.com/albertsyh/orama"},"license":"Apache-2.0","readme":"<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/oramasearch/orama/refs/heads/main/misc/readme/orama-readme-hero-light.png#gh-light-mode-only\" />\n</p>\n\n[![Tests](https://github.com/oramasearch/orama/actions/workflows/turbo.yml/badge.svg)](https://github.com/oramasearch/orama/actions/workflows/turbo.yml)\n\nIf you need more info, help, or want to provide general feedback on Orama, join the [Orama Slack channel](https://orama.to/slack)\n\n# Highlighted features\n\n- [Full-Text search](https://docs.orama.com/open-source/usage/search/introduction)\n- [Vector Search](https://docs.orama.com/open-source/usage/search/vector-search)\n- [Hybrid Search](https://docs.orama.com/open-source/usage/search/hybrid-search)\n- [GenAI Chat Sessions](https://docs.orama.com/open-source/usage/answer-engine/introduction)\n- [Search Filters](https://docs.orama.com/open-source/usage/search/filters)\n- [Geosearch](https://docs.orama.com/open-source/usage/search/geosearch)\n- [Facets](https://docs.orama.com/open-source/usage/search/facets)\n- [Fields Boosting](https://docs.orama.com/open-source/usage/search/fields-boosting)\n- [Typo Tolerance](https://docs.orama.com/open-source/usage/search/introduction#typo-tolerance)\n- [Exact Match](https://docs.orama.com/open-source/usage/search/introduction#exact-match)\n- [BM25](https://docs.orama.com/open-source/usage/search/bm25-algorithm)\n- [Stemming and tokenization in 30 languages](https://docs.orama.com/open-source/text-analysis/stemming)\n- [Plugin System](https://docs.orama.com/open-source/plugins/introduction)\n\n# Installation\n\nYou can install Orama using `npm`, `yarn`, `pnpm`, `bun`:\n\n```sh\nnpm i @orama/orama\n```\n\nOr import it directly in a browser module:\n\n```html\n<html>\n  <body>\n    <script type=\"module\">\n      import { create, insert, search } from 'https://cdn.jsdelivr.net/npm/@orama/orama@latest/+esm'\n    </script>\n  </body>\n</html>\n```\n\nWith Deno, you can just use the same CDN URL or use npm specifiers:\n\n```js\nimport { create, search, insert } from 'npm:@orama/orama'\n```\n\nRead the complete documentation at [https://docs.orama.com](https://docs.orama.com).\n\n# Orama Features\n\n<p align=\"center\">\n  <img src=\"https://raw.githubusercontent.com/oramasearch/orama/refs/heads/main/misc/readme/features-light.png#gh-light-mode-only\" />\n</p>\n\n# Usage\n\nOrama is quite simple to use. The first thing to do is to create a new database\ninstance and set an indexing schema:\n\n```js\nimport { create, insert, remove, search, searchVector } from '@orama/orama'\n\nconst db = create({\n  schema: {\n    name: 'string',\n    description: 'string',\n    price: 'number',\n    embedding: 'vector[1536]', // Vector size must be expressed during schema initialization\n    meta: {\n      rating: 'number',\n    },\n  },\n})\n\ninsert(db, {\n  name: 'Noise cancelling headphones',\n  description: 'Best noise cancelling headphones on the market',\n  price: 99.99,\n  embedding: [0.2432, 0.9431, 0.5322, 0.4234, ...],\n  meta: {\n    rating: 4.5\n  }\n})\n\nconst results = search(db, {\n  term: 'Best headphones'\n})\n\n// {\n//   elapsed: {\n//     raw: 21492,\n//     formatted: '21μs',\n//   },\n//   hits: [\n//     {\n//       id: '41013877-56',\n//       score: 0.925085832971998432,\n//       document: {\n//         name: 'Noise cancelling headphones',\n//         description: 'Best noise cancelling headphones on the market',\n//         price: 99.99,\n//         embedding: [0.2432, 0.9431, 0.5322, 0.4234, ...],\n//         meta: {\n//           rating: 4.5\n//         }\n//       }\n//     }\n//   ],\n//   count: 1\n// }\n```\n\nOrama currently supports 10 different data types:\n\n| Type             | Description                                                                 | Example                                                                     |\n| ---------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- |\n| `string`         | A string of characters.                                                     | `'Hello world'`                                                             |\n| `number`         | A numeric value, either float or integer.                                   | `42`                                                                        |\n| `boolean`        | A boolean value.                                                            | `true`                                                                      |\n| `enum`           | An enum value.                                                              | `'drama'`                                                                   |\n| `geopoint`       | A geopoint value.                                                           | `{ lat: 40.7128, lon: 74.0060 }`                                            |\n| `string[]`       | An array of strings.                                                        | `['red', 'green', 'blue']`                                                  |\n| `number[]`       | An array of numbers.                                                        | `[42, 91, 28.5]`                                                            |\n| `boolean[]`      | An array of booleans.                                                       | `[true, false, false]`                                                      |\n| `enum[]`         | An array of enums.                                                          | `['comedy', 'action', 'romance']`                                           |\n| `vector[<size>]` | A vector of numbers to perform vector search on.                            | `[0.403, 0.192, 0.830]`                                                     |\n\n# Vector and Hybrid Search Support\n\nOrama supports both vector and hybrid search by just setting `mode: 'vector'` when performing search.\n\nTo perform this kind of search, you'll need to provide [text embeddings](https://en.wikipedia.org/wiki/Word_embedding) at search time:\n\n```js\nimport { create, insertMultiple, search } from '@orama/orama'\n\nconst db = create({\n  schema: {\n    title: 'string',\n    embedding: 'vector[5]'', // we are using a 5-dimensional vector.\n  },\n});\n\ninsertMultiple(db, [\n  { title: 'The Prestige', embedding: [0.938293, 0.284951, 0.348264, 0.948276, 0.56472] },\n  { title: 'Barbie', embedding: [0.192839, 0.028471, 0.284738, 0.937463, 0.092827] },\n  { title: 'Oppenheimer', embedding: [0.827391, 0.927381, 0.001982, 0.983821, 0.294841] },\n])\n\nconst results = search(db, {\n  // Search mode. Can be 'vector', 'hybrid', or 'fulltext'\n  mode: 'vector',\n  vector: {\n    // The vector (text embedding) to use for search\n    value: [0.938292, 0.284961, 0.248264, 0.748276, 0.26472],\n    // The schema property where Orama should compare embeddings\n    property: 'embedding',\n  },\n  // Minimum similarity to determine a match. Defaults to `0.8`\n  similarity: 0.85,\n  // Defaults to `false`. Setting to 'true' will return the embeddings in the response (which can be very large).\n  includeVectors: true,\n})\n```\n\nHave trouble generating embeddings for vector and hybrid search? Try our `@orama/plugin-embeddings` plugin!\n\n```js\nimport { create } from '@orama/orama'\nimport { pluginEmbeddings } from '@orama/plugin-embeddings'\nimport '@tensorflow/tfjs-node' // Or any other appropriate TensorflowJS backend, like @tensorflow/tfjs-backend-webgl\n\nconst plugin = await pluginEmbeddings({\n  embeddings: {\n    // Schema property used to store generated embeddings\n    defaultProperty: 'embeddings',\n    onInsert: {\n      // Generate embeddings at insert-time\n      generate: true,\n      // properties to use for generating embeddings at insert time.\n      // Will be concatenated to generate a unique embedding.\n      properties: ['description'],\n      verbose: true,\n    }\n  }\n})\n\nconst db = create({\n  schema: {\n    description: 'string',\n    // Orama generates 512-dimensions vectors.\n    // When using @orama/plugin-embeddings, set the property where you want to store embeddings as `vector[512]`.\n    embeddings: 'vector[512]'\n  },\n  plugins: [plugin]\n})\n\n// Orama will generate and store embeddings at insert-time!\nawait insert(db, { description: 'Classroom Headphones Bulk 5 Pack, Student On Ear Color Varieties' })\nawait insert(db, { description: 'Kids Wired Headphones for School Students K-12' })\nawait insert(db, { description: 'Kids Headphones Bulk 5-Pack for K-12 School' })\nawait insert(db, { description: 'Bose QuietComfort Bluetooth Headphones' })\n\n// Orama will also generate and use embeddings at search time when search mode is set to \"vector\" or \"hybrid\"!\nconst searchResults = await search(db, {\n  term: 'Headphones for 12th grade students',\n  mode: 'vector'\n})\n```\n\nWant to use OpenAI embedding models? Use our [Secure Proxy](https://docs.orama.com/open-source/plugins/plugin-secure-proxy) plugin to call OpenAI from the client-side securely.\n\n# RAG and Chat Experiences with Orama\n\nSince `v3.0.0`, Orama allows you to create your own ChatGPT/Perplexity/SearchGPT-like experience. You will need to call the OpenAI APIs, so we strongly recommend using the [Secure Proxy Plugin](https://docs.orama.com/open-source/plugins/plugin-secure-proxy) to do that securely from your client side. It's free!\n\n```js\nimport { create, insert } from '@orama/orama'\nimport { pluginSecureProxy } from '@orama/plugin-secure-proxy'\n\nconst secureProxy = await pluginSecureProxy({\n  apiKey: 'my-api-key',\n  defaultProperty: 'embeddings',\n  models: {\n    // The chat model to use to generate the chat answer\n    chat: 'openai/gpt-4o-mini'\n  }\n})\n\nconst db = create({\n  schema: {\n    name: 'string'\n  },\n  plugins: [secureProxy]\n})\n\ninsert(db, { name: 'John Doe' })\ninsert(db, { name: 'Jane Doe' })\n\nconst session = new AnswerSession(db, {\n  // Customize the prompt for the system\n  systemPrompt: 'You will get a name as context, please provide a greeting message',\n  events: {\n    // Log all state changes. Useful to reactively update a UI on a new message chunk, sources, etc.\n    onStateChange: console.log,\n  }\n})\n\nconst response = await session.ask({\n  term: 'john'\n})\n\nconsole.log(response) // Hello, John Doe! How are you doing?\n```\n\nRead the complete documentation [here](https://docs.orama.com/open-source/usage/answer-engine/introduction).\n\n# Official Docs\n\nRead the complete documentation at [https://docs.orama.com/open-source](https://docs.orama.com/open-source).\n\n# Official Orama Plugins\n\n- [Plugin Embeddings](https://docs.orama.com/open-source/plugins/plugin-embeddings)\n- [Plugin Secure Proxy](https://docs.orama.com/open-source/plugins/plugin-secure-proxy)\n- [Plugin Analytics](https://docs.orama.com/open-source/plugins/plugin-analytics)\n- [Plugin Data Persistence](https://docs.orama.com/open-source/plugins/plugin-data-persistence)\n- [Plugin QPS](https://docs.orama.com/open-source/plugins/plugin-qps)\n- [Plugin PT15](https://docs.orama.com/open-source/plugins/plugin-pt15)\n- [Plugin Vitepress](https://docs.orama.com/open-source/plugins/plugin-vitepress)\n- [Plugin Docusaurus](https://docs.orama.com/open-source/plugins/plugin-docusaurus)\n- [Plugin Astro](https://docs.orama.com/open-source/plugins/plugin-astro)\n- [Plugin Nextra](https://docs.orama.com/open-source/plugins/plugin-nextra)\n\nWrite your own plugin: [https://docs.orama.com/open-source/plugins/writing-your-own-plugins](https://docs.orama.com/open-source/plugins/writing-your-own-plugins)\n\n# License\n\nOrama is licensed under the [Apache 2.0](/LICENSE.md) license.\n","readmeFilename":"README.md"}