If you are building a website, e-commerce, a blog, etc., you will need a full-text search to find related content like Google does for every web page. This is an already known problem so probably you don't want to implement your own solution.
This project is a Proof of Concept that uses the module flexsearch
It exposes a web service using Express that allows request like this:
http://localhost:3000/search?phrase=Cloud
See the step by step here:
https://javaniceday.com/2019/06/29/full-text-search-in-node-js-search-related-data/