Skip to main content

OpenSearch

Overview

The following document will cover

  • Our local development images
  • How to setup a decoupled local development environment

Local Development Images

Skpr provides developers with local development images for OpenSearch 1.x, 2.x and 3.x.

docker.io/skpr/opensearch:dev-v2-1.x
docker.io/skpr/opensearch:dev-v2-2.x
docker.io/skpr/opensearch:dev-v2-3.x

Decoupled Local Development Environment

Docker Compose

The below Docker Compose file can be used as a reference for your local environment.

It does not include the full stack eg. PHP, Mysql, Node, Mail etc.

services:

# This container is used for all other containers to connect to for a shared network stack.
network:
image: alpine:3.21
stdin_open: true
ports:
- "${OPENSEARCH_PORT:-9200}:9200"

nginx:
image: skpr/nginx-drupal:dev-v2-latest
network_mode: service:network
volumes:
- ./docker/compose/nginx/overrides.d/opensearch.conf:/etc/nginx/conf.d/location/60-opensearch.conf

opensearch:
image: docker.io/skpr/opensearch:dev-v2-2.x
network_mode: service:network
volumes:
- opensearch-data:/usr/share/opensearch/data

volumes:
opensearch-data:

Nginx

The configuration file below will add a route /api/v1/opensearch for decoupled applications which uses read only credentials.

location /api/v1/opensearch/ {
proxy_pass http://127.0.0.1:9200/;
proxy_set_header Authorization "Basic cmVhZGVyOnJlYWRlcg==";
}

Drupal

Finally, using the Search API OpenSearch Drupal module you can index content into OpenSearch so it can be directly queried using our new endpoint.

Below is example settings.php configuration for connecting to the OpenSearch instance.

<?php

$config['search_api.server.CHANGE_ME']['backend_config']['connector_config']['url'] = $skpr->get('opensearch.writer.endpoint', 'http://127.0.0.1:9200');
$config['search_api.server.CHANGE_ME']['backend_config']['connector_config']['username'] = $skpr->get('opensearch.writer.username', 'writer');
$config['search_api.server.CHANGE_ME']['backend_config']['connector_config']['password'] = $skpr->get('opensearch.writer.password', 'writer');
$config['search_api.server.CHANGE_ME']['backend_config']['advanced']['prefix'] = $skpr->get('opensearch.writer.index_prefix', 'local_');