Overview

The following article was helpful for integrating Strapi with Elasticsearch.

https://punits.dev/blog/integrating-elasticsearch-with-strapi/

The source code is also publicly available.

https://github.com/geeky-biz/strapi-integrate-elasticsearch

Here, I will note some customizations made based on the above article, including integration with Amazon OpenSearch.

The customized source code is available here:

https://github.com/nakamura196/strapi-integrate-opensearch

Modifications

The article references indexing_type, but it needed to be changed to indexing_request_type.

https://github.com/nakamura196/strapi-integrate-opensearch/blob/006c533d4d7882fc9779552db31a7b0e2ada5e57/elastic/cron-search-indexing.js#L16

Additionally, to use Amazon OpenSearch instead of Elasticsearch, the following libraries need to be installed.

nnppmmiinnssttaallll@@oapwesn-ssedakr/cchr-epdreonjteicatl/-oppreonvsiedaerrcsh

There are several authentication methods available, but here I made the following changes.

https://github.com/nakamura196/strapi-integrate-opensearch/blob/006c533d4d7882fc9779552db31a7b0e2ada5e57/elastic/elasticClient.js#L1C1-L30

The index registration and deletion processes also needed to be modified as follows.

https://github.com/nakamura196/strapi-integrate-opensearch/blob/006c533d4d7882fc9779552db31a7b0e2ada5e57/elastic/elasticClient.js#L39-L44

As a result of these modifications, I was able to connect Strapi with Amazon OpenSearch.

By modifying elastic/elasticClient.js and src/api/search/controllers/search.js, I was also able to customize the API output. This enabled the use of Elasticsearch Aggregations. (Due to my limited investigation, this may also be achievable with Strapi alone.)

Summary

I hope this serves as a helpful reference for integrating Strapi with Amazon OpenSearch.