DEV Community

eleonorarocchi
eleonorarocchi

Posted on

How to start with OramaSearch

In this last week, I wanted to try OramaSearch, a new library that is really easy to use to implement fulltext searches.

I wanted to do two simple tests to verify its ease of use and if indeed, as the authors promise, provide results so quickly.

The first test was to create an Angular project, add a service that downloaded a structured JSON of data (in my case related to a list of states of the world), and then use Orama to filter the data based on a text string.

The steps to include and use Orama are:

  1. create an angular project Create an angular project
  2. install OramaSearch Install OramaSearch
  3. create a service to download data from a webservice Create a service to download data from a webservice In my case I used https://restcountries.com, an Open Source project and free to use, to get country information via a RESTful API.
  4. create a database with the desired schema Create a database with the desired schema
  5. through the service, populate the database Through the service, populate the database
  6. create an interface to display the data list, including search fields (in my case I used AngularMaterial to speed up writing the UI)
  7. implement search method Implement search method

If you want to see the complete project, you can find it here https://github.com/eleonorarocchi/oramaDemo

The second test was to implement a NodeJs project.
As in the previous example, I tried including CountryREST to populate the database, and implement a search method.

The steps to include and use Orama are:

  1. initialize it as an npm project: Initialize it as an npm project
  2. install and set up TypeScript Install and set up TypeScript
  3. create tsconfig.json Create tsconfig.json
  4. install the Express framework and create a minimal server Install the Express framework
  5. create src/app.ts file
  6. in the app.listen method, add the code for initialize the database definition, as in the previous project, and the code for populate database Populate db
  7. create a method for see all data See all data
  8. create a method for see filtered data, by a parameter Filter data

It's really simple to integrate and fast to deliver results!

If you want to see the complete project, you can find it here https://github.com/eleonorarocchi/oramaNodeDemo

https://www.oramasearch.com

You can find more information directly on the project website: https://www.oramasearch.com

Top comments (0)