We took a similar approach for our documentation search. [0]
You can see the "inverted index" is rendered inline in the page, since everything is generated at build time.
When you type something that matches a key in the index, we fetch that index key and add it to the results. [1] [2]
Obviously we could do a lot better in terms of relevancy, but it's simple and fast.
[0] https://docs.fastcomments.com/
[1] https://docs.fastcomments.com/index-ublJLBnXgz88.json
[2] https://github.com/FastComments/fastcomments-docs/blob/main/...