{"name":"@orama/orama","version":"1.0.0","keywords":["full-text search","search","fuzzy search","typo-tolerant search","full-text"],"author":{"url":"https://github.com/MicheleRiva","name":"Michele Riva","email":"michele.riva@oramasearch.com"},"license":"Apache-2.0","_id":"@orama/orama@1.0.0","maintainers":[{"name":"micheleriva","email":"master@micheleriva.it"}],"contributors":[{"url":"http://cowtech.it","name":"Paolo Insogna","email":"paolo.insogna@oramasearch.com"}],"homepage":"https://github.com/oramasearch/orama#readme","bugs":{"url":"https://github.com/oramasearch/orama"},"dist":{"shasum":"2fc217ea67f86edc9f204f18c31fe104bdee2924","tarball":"http://registry-npm.ywwl.com/@orama/orama/download/@orama/orama-1.0.0.tgz","fileCount":151,"integrity":"sha512-S4ZkcA1B+Nh4RUlDxcr8mt4kmObLHYqtcY6xmNCqjM2Tzs0wAnJ/OyvS1kZkqiFF6eusnWz7XfMPiwcCxyxmeA==","signatures":[{"sig":"MEQCICtxwoOr5Xi4z4LWb6Bbbq1damUtNooebtZAZyTiKJVMAiAbnQy8F2/iCYBs4Qw1rywjkcgqnjmjrQa2hR9r7a093A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":485221,"size":117789,"noattachment":false,"key":"/@orama/orama/-/@orama/orama-1.0.0.tgz"},"main":"./dist/cjs/index.cjs","type":"module","_from":"file:orama-orama-1.0.0.tgz","types":"./dist/index.d.ts","engines":{"node":">= 16.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/cjs/index.cjs"},"./internals":{"types":"./dist/internals.d.ts","import":"./dist/internals.js","require":"./dist/cjs/internals.cjs"},"./components":{"types":"./dist/components.d.ts","import":"./dist/components.js","require":"./dist/cjs/components.cjs"}},"scripts":{"ci":"npm run build && npm run test:ci && npm run test:smoke","dev":"swc -s -w --extensions .ts,.cts -d dist src","lint":"eslint src tests --ext .js,.ts,.cts","test":"c8 -c tests/config/c8-local.json tap --rcfile=tests/config/tap.yml tests/*.test.ts","build":"node scripts/build.js","predev":"rm -rf dist && mkdir dist","test:ci":"c8 -c tests/config/c8-ci.json tap --rcfile=tests/config/tap.yml --no-color tests/*.test.ts","prebuild":"npm run lint","test:smoke":"tap --rcfile=tests/config/tap.yml tests/smoke/*.test.ts"},"_npmUser":{"name":"micheleriva","email":"master@micheleriva.it"},"_resolved":"/private/var/folders/7r/_gnlk01s33d4bdffh9zx238r0000gn/T/de5ef647de803c7a7002032fba37e932/orama-orama-1.0.0.tgz","_integrity":"sha512-S4ZkcA1B+Nh4RUlDxcr8mt4kmObLHYqtcY6xmNCqjM2Tzs0wAnJ/OyvS1kZkqiFF6eusnWz7XfMPiwcCxyxmeA==","repository":{"url":"git+https://github.com/oramasearch/orama.git","type":"git"},"_npmVersion":"9.5.0","description":"Next generation full-text search engine, written in TypeScript","directories":{},"sideEffects":false,"_nodeVersion":"18.15.0","_hasShrinkwrap":false,"devDependencies":{"c8":"^7.12.0","tap":"^16.3.2","tsx":"^3.12.1","glob":"^9.2.3","tape":"^5.6.1","vite":"^4.1.4","execa":"^6.1.0","@swc/cli":"^0.1.59","prettier":"^2.8.1","tcompare":"^6.0.0","@swc/core":"^1.3.27","@types/tap":"^15.0.7","commitizen":"^4.2.6","cronometro":"^1.1.5","typescript":"^4.9.4","@types/node":"^18.11.18","auto-changelog":"^2.4.0","@orama/stemmers":"1.0.0","@playwright/test":"^1.29.2","tap-mocha-reporter":"^5.0.3"},"_npmOperationalInternal":{"tmp":"tmp/orama_1.0.0_1685018379619_0.0540325920052247","host":"s3://npm-registry-packages"},"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/docs/orama-js/search)\n- [Vector Search](https://docs.orama.com/docs/orama-js/search/vector-search)\n- [Hybrid Search](https://docs.orama.com/docs/orama-js/search/hybrid-search)\n- [GenAI Chat Sessions](https://docs.orama.com/docs/orama-js/answer-engine)\n- [Search Filters](https://docs.orama.com/docs/orama-js/search/filters)\n- [Geosearch](https://docs.orama.com/docs/orama-js/search/geosearch)\n- [Pinning Rules (Merchandising)](https://docs.orama.com/docs/orama-js/results-pinning)\n- [Facets](https://docs.orama.com/docs/orama-js/search/facets)\n- [Fields Boosting](https://docs.orama.com/docs/orama-js/search/fields-boosting)\n- [Typo Tolerance](https://docs.orama.com/docs/orama-js/search#typo-tolerance)\n- [Exact Match](https://docs.orama.com/docs/orama-js/search#exact-match)\n- [BM25](https://docs.orama.com/docs/orama-js/search/bm25)\n- [Stemming and tokenization in 30 languages](https://docs.orama.com/docs/orama-js/text-analysis/stemming)\n- [Plugin System](https://docs.orama.com/docs/orama-js/plugins)\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/docs/orama-js/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/docs/orama-js/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/docs/orama-js/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/docs/orama-js/plugins/plugin-embeddings)\n- [Plugin Secure Proxy](https://docs.orama.com/docs/orama-js/plugins/plugin-secure-proxy)\n- [Plugin Analytics](https://docs.orama.com/docs/orama-js/plugins/plugin-analytics)\n- [Plugin Data Persistence](https://docs.orama.com/docs/orama-js/plugins/plugin-data-persistence)\n- [Plugin QPS](https://docs.orama.com/docs/orama-js/plugins/plugin-qps)\n- [Plugin PT15](https://docs.orama.com/docs/orama-js/plugins/plugin-pt15)\n- [Plugin Vitepress](https://docs.orama.com/docs/orama-js/plugins/plugin-vitepress)\n- [Plugin Docusaurus](https://docs.orama.com/docs/orama-js/plugins/plugin-docusaurus)\n- [Plugin Astro](https://docs.orama.com/docs/orama-js/plugins/plugin-astro)\n- [Plugin Nextra](https://docs.orama.com/docs/orama-js/plugins/plugin-nextra)\n\nWrite your own plugin: [https://docs.orama.com/docs/orama-js/plugins/writing-your-own-plugins](https://docs.orama.com/docs/orama-js/plugins/writing-your-own-plugins)\n\n# License\n\nOrama is licensed under the [Apache 2.0](/LICENSE.md) license.\n\n<img referrerpolicy=\"no-referrer-when-downgrade\" src=\"https://static.scarf.sh/a.png?x-pxid=fb0c2057-e709-49a9-b634-cf90bdfb2dbd\" />","publish_time":1685018379887,"_cnpm_publish_time":1685018379887,"dist-tags":{"latest":"3.1.18"}}