Getting Started with OramaOrama is a fast, batteries-included, full-text and vector search engine entirely written in TypeScript, with zero dependencies.
Get started with just a few lines of code:
import { create, insert, search } from "@orama/orama";
const db = await create({
schema: {
title: "string",
director: "string",
isFavorite: "boolean",
year: "number",
},
});
await insert(db, {
title: "The Prestige",
director: "Christopher Nolan",
isFavorite: true,
year: 2006,
});
const searchResults = await search(db, {
term: "prestige",
where: {
isFavorite: true,
year: {
between: [2000, 2008],
},
},
});
Js
RequirementsA JavaScript runtime is the only requirement. Orama has been designed to work on any runtime and has no dependencies.
InstallationYou can install Orama using npm, yarn, pnpm:
npm i @orama/orama
Sh
Or import it directly in a browser module:
<html>
<body>
<script type="module">
import {
create,
search,
insert,
} from "https://unpkg.com/@orama/orama@latest/dist/index.js";
// ...
</script>
</body>
</html>
Html
Basic usageimport { create, search, insert } from "@orama/orama";
const db = await create({
schema: {
name: "string",
description: "string",
price: "number",
meta: {
rating: "number",
},
},
});
await insert(db, {
name: "Wireless Headphones",
description:
"Experience immersive sound quality with these noise-cancelling wireless headphones.",
price: 99.99,
meta: {
rating: 4.5,
},
});
const searchResult = await search(db, {
term: "headphones",
});
console.log(searchResult.hits.map((hit) => hit.document));
Ts
For more information, check out the Usage section.
CommonJS ImportsOrama ships ESM modules by default. This allows us to move faster when providing new features and bug fixes, as well as using the "exports"
field in package.json
to provide a better developer experience.
CommonJS imports are still supported, but we suggest you to migrate to ESM.
TypeScriptSet moduleResolution
in the compilerOptions
in your tsconfig.json
to be either Node16
or NodeNext
.
When importing types, always refer to the standard orama import:
import type { Language } from "@orama/orama";
Ts
Community RewardsAre you using Orama in production? Have you written an article or made a YouTube video on Orama? Contact us to get some Orama swag in return!