I had no difficulty creating an Elasticsearch index on the Bonsai commercial service as documented in the links found on https://gohugo.io/tools/search/. I can query it using the curl CLI tool. What I can’t find are any straightforward directions for embedding a search box on my Hugo based blog that utilizes that index. This page explaining how to add a search box backed by Lunr is the sort of thing I’m looking for but for an Elasticsearch index. I’m not a frontend engineer. Despite a couple of hours googling and browsing sites like https://www.elastic.co/ I haven’t been able to find a simple “drop this into your Hugo site to enable Elasticsearch backed searching” solution.

Even though my blog is small (~400 articles over 5 years) I would prefer not to use a solution like Lunr which requires the client to load a large file since that doesn’t scale and can result in a poor user experience.

Thanks, @maiki, but I’m looking for equivalent resources for how to incorporate Elasticsearch into a Hugo site. It seems like the assumption is that anyone wanting to use Elasticsearch will be doing so in a commercial setting and thus will have the expertise and staff to wade through all the ES documentation and craft a solution from scratch.

Oops. My mistake, I thought that krader1961 wanted to use commercial Elastic aka Swiftype. I can afford to do that, since my site is documentation for a software company. With the assistance of a former sales engineer from Lucidworks, I was able to generate JSON for searching, using only Hugo. I don’t know if I still have that around.

*The middleware can be on it’s own server or on the same server as Elasticsearch using Apache or something similar. Again I’m not an expert in this field so IDK if putting them on the same server would be good or bad in the long run.

I’d create a simple API on the middle-ware server based on my needs. This is good since none of your Elasticsearch credentials get exposed to the client. They remain on that middleware server.

Algolia

It involves generating a JSON file for search, but it’s not for users to download in the browser. It’s sent to Algolia to update the database so it scales much better than Lunr for large indexes. After you sync things up you can use Algolia’s instantsearch.js libary on your hugo website to search for results in your index. https://community.algolia.com/instantsearch.js/v2/getting-started.html

Algolia is a SaaS but it has a generous free tier

Swiftype

A commercial product by elastic. It allows you to add search to your site with by pasting a bit of code. It starts at $79/month though

No worries, @jmalin. But I’m definitely not going to spend $80/month for the ability to search my personal blog Even the $8/month of a commercial provisioner of the Elasticsearch service is hard to justify. But I figured that I could side-step even those minimal costs by running my own Elasticsearch instance.

Since it looks like there is no “do x, y, then z” to get even the most basic integration with a service like bonsai.com working I’ll probably just use Lunr and accept that the solution doesn’t scale.

Thanks for the detailed response, @joshmossas. I had already deduced that I would need some middleware to run alongside Caddy (the web server I use for providing access to my Hugo based blog). I was unable to find a “here’s how to do a basic implementation” article somewhere and was sad my google-fu didn’t find any relevant articles.

I had glanced at Algolia but didn’t proceed past their main web site page. I’ll take a closer look at that as a possible solution. Barring that I’ll fall back to Lunr.