I'm not sure Elastic can be used directly from JS, you should check if there are public offerings with a sdk on top.
Algolia has a JS client only sdk for search.
DEV search runs on Algolia so I know it's fine for this kind of usage...
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.