Orama

Fast, dependency-free, full-text and vector search engine with typo toleran...

README

orama


Full-text, vector, and hybrid search with a unique API.

On your browser, server, mobile app, or at the edge.
  In less than 2kb.

Join Orama's Slack channel


If you need more info, help, or want to provide general feedback on Orama, join
the

Installation


You can install Orama using npm, yarn, pnpm, bun:

  1. ```sh
  2. npm i @orama/orama
  3. ```

Or import it directly in a browser module:

  1. ```html
  2. <html>
  3.   <body>
  4.     <script type="module">
  5.       import { create, search, insert } from 'https://unpkg.com/@orama/orama@latest/dist/index.js'
  6.       // ...
  7.     </script>
  8.   </body>
  9. </html>
  10. ```

With Deno, you can just use the same CDN URL or use npm specifiers:

  1. ```js
  2. import { create, search, insert } from 'npm:@orama/orama'
  3. ```

Read the complete documentation at https://docs.oramasearch.com.

Usage


Orama is quite simple to use. The first thing to do is to create a new database
instance and set an indexing schema:

  1. ```js
  2. import { create, insert, remove, search, searchVector } from '@orama/orama'

  3. const db = await create({
  4.   schema: {
  5.     name: 'string',
  6.     description: 'string',
  7.     price: 'number',
  8.     embedding: 'vector[1536]', // Vector size must be expressed during schema initialization
  9.     meta: {
  10.       rating: 'number',
  11.     },
  12.   },
  13. })
  14. ```

Orama currently supports 10 different data types:

TypeDescriptionexample
---------
`string`A`'Hello
`number`A`42`
`boolean`A`true`
`enum`An`'drama'`
`geopoint`A`{
`string[]`An`['red',
`number[]`An`[42,
`boolean[]`An`[true,
`enum[]`An`['comedy',
`vector[]`A`[0.403,

Orama will only index properties specified in the schema but will allow you to set and store additional data if needed.

Once the db instance is created, you can start adding some documents:

  1. ```js
  2. await insert(db, {
  3.   name: 'Wireless Headphones',
  4.   description: 'Experience immersive sound quality with these noise-cancelling wireless headphones.',
  5.   price: 99.99,
  6.   embedding: [...],
  7.   meta: {
  8.     rating: 4.5,
  9.   },
  10. })

  11. await insert(db, {
  12.   name: 'Smart LED Bulb',
  13.   description: 'Control the lighting in your home with this energy-efficient smart LED bulb, compatible with most smart home systems.',
  14.   price: 24.99,
  15.   embedding: [...],
  16.   meta: {
  17.     rating: 4.3,
  18.   },
  19. })

  20. await insert(db, {
  21.   name: 'Portable Charger',
  22.   description: 'Never run out of power on-the-go with this compact and fast-charging portable charger for your devices.',
  23.   price: 29.99,
  24.   embedding: [...],
  25.   meta: {
  26.     rating: 3.6,
  27.   },
  28. })
  29. ```

After the data has been inserted, you can finally start to query the database.

  1. ```js
  2. const searchResult = await search(db, {
  3.   term: 'headphones',
  4. })
  5. ```