How to Set Up and Use Elasticsearch with Strapi

The need for a search feature in an application cannot be overstated. It could make the life of users easier and also make them excited to use an application. The ease of finding a particular resource or a collection of resources on an application greatly affects the user experience of an application (web or mobile).


This is a companion discussion topic for the original entry at https://strapi.io/blog/how-to-set-up-and-use-elasticsearch-with-strapi

Hello there,
I’m using strapi v4 and follow all your steps to integrate elasticsearch to my strapi. Actually, I got this error. How can I solve that? Thank you

We managed to solve this by changing the query to elasticsearch, it is malformed in the demo.

As an example, this worked just fine:

body: {
          query: {
            bool: {
              should: [
                { term: { "attributes.title": "purple" } }
              ]
            }
          }
        }

Hi, I need to override this controller to get the default strapi response with the data and meta object for clean and standard responses and pagination from the search result.

code:
search_restaurants: async(ctx, next) => {
try {
const data = await strapi.service(‘api::search.search’).search_restaurants(ctx.query)
// console.log(‘here’, ctx.query)
ctx.body = data
} catch (err) {
ctx.body = err;
}
}

desire response schema:
Screenshot 2023-10-05 173354

its there any example for implementing this feature?
Thanks so much!