Skip to content

Elasticsearch

Part of the Sidecar Services catalog.

What it does

Elasticsearch is a search and analytics engine. As a sidecar it backs faceted search, full-text queries, and aggregations on a project locally, standing in for a hosted Elasticsearch cluster the production site queries. Add it when project code (often through ElasticPress or a custom client) indexes content and runs search against Elasticsearch and you want that running on your machine.

For WP VIP Enterprise Search specifically, use wpvip-search instead. That preset pins the 7.10.x line VIP runs and injects the VIP and ElasticPress env vars.

How it works

The preset pins docker.elastic.co/elasticsearch/elasticsearch:8.13.0 and listens on container port 9200. It runs as a single node with security disabled (discovery.type=single-node, xpack.security.enabled=false) and a fixed 512m heap, which keeps a local instance light and avoids TLS and credential setup. The index persists in a named volume mounted at /usr/share/elasticsearch/data.

Elasticsearch gets a browser UI: the host port is auto-allocated from the 7000 to 7999 range and de-conflicted across all projects.

bash
wdg my-site service add elasticsearch
wdg my-site service list

Read the browser URL from the service list output.

How it integrates with the local WordPress container

Adding the sidecar injects these env vars into the WordPress container:

VariableValue
ELASTICSEARCH_HOSTwdg-my-site-elasticsearch (the @HOST token resolved at add-time)
ELASTICSEARCH_PORT9200

WordPress reaches Elasticsearch over wdg-network at wdg-my-site-elasticsearch:9200, never the host port. The host port exists only for your browser.

These env vars are connectivity hints. The project supplies the code that consumes them. If the site uses ElasticPress, point its host constant at the injected values, for example in wp-config.php:

php
define( 'EP_HOST', 'http://' . getenv( 'ELASTICSEARCH_HOST' ) . ':' . getenv( 'ELASTICSEARCH_PORT' ) );

The single-node, security-disabled mode means no username or password is needed for a local connection. Adding the sidecar wires reachability only; the project installs the search plugin and indexes content.

Add and remove

bash
wdg my-site service add elasticsearch
wdg my-site service remove elasticsearch          # keeps the data volume
wdg my-site service remove elasticsearch --purge  # also deletes the data volume