What Is OramaSearch
Welcome to OpenDev Explorer, where I explore the Open Source world with an eye on developer experience. I am Riccardo (aka TheZal), and today I will talk to you about OramaSearch, an open-source search engine with a “battery included” and zero dependencies.
General Overview
“It’s not the finding, but the searching” is one of the mottos of OramaSearch, an open-source search engine ready out of the box and with zero dependencies. Originally named Lyra as an exercise for a talk by Michele Riva to explain how a full-text search engine works, it has since become a real project thanks to the feedback from the community (5800 stars on GitHub and thousands of downloads in a few months) who found in Orama Search a powerful and optimized search engine that is simple to use and able to meet all the community’s requests.
Instruction Manual
Installation
Installing OramaSearch is very simple; it is available on all major package managers (npm, yarn, pnpm) and can be installed with a simple command:
npm i @orama/orama
Code language: CSS (css)
Or you can directly import it into 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>
Code language: HTML, XML (xml)
Usage
First, you need to create a new instance (from now on database) with an index schema.
The schema represents the searchable properties of the document to be inserted into the database. It is also possible to have additional unindexed properties, as long as these are not needed in the search.
An example of usage (taken directly from the official documentation) is as follows:
import { 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))
Code language: JavaScript (javascript)
The Developer Experience With OramaSearch
The greatest success of Orama Search is that the community turned it into a real project (and product). The community has acclaimed Orama thanks to its fantastic developer experience and simplicity of use.
Several points improve the developer experience of OramaSearch:
1 – The documentation is clear and well-done
2 – The community is very active and responds very quickly to questions asked on GitHub or Slack
3 – The library is very well written and allows you to start using it in a few minutes
4 – Orama provides several official plugins that allow the use of Orama in different contexts (such as on Astro)
The Extra Mile
OramaSearch has some features that give it an extra mile, making it a very powerful and flexible search engine.
Having been designed to contain a vector database inside, OramaSearch natively implements vector search of elements.
It also implements geo-search functionality, allowing searching for elements based on their geographical location.
Comparison with the Status Quo
There are several full-text search engines (such as ElasticSearch), but I don’t think there is one on the market that has the same arsenal as OramaSearch.
However, I am sure that at the moment there is no utility as powerful as Orama that shares its simplicity of use, making Orama Search unique in its kind.
Regarding search speed, Orama Search is one of the fastest search engines I have ever tried, and this is another point in its favor.