Skip to main content

OpenSearch Overview

The OPENSEARCH connector indexes MQTT messages as documents in OpenSearch and publishes search results back to MQTT. Each event either indexes one document or runs one search, and models can store into an index with STORE IN. The connector talks to the OpenSearch REST API over HTTP or HTTPS, with basic authentication.
OpenSearch suits logs, events, and sensor data you want to search and chart. Connect OpenSearch Dashboards to the same indices for visualizations.
When to use it: full-text search across messages, dashboards over recent data, and log or event archives. For a table with a fixed schema, use a SQL connector such as PostgreSQL.

Quick Start

Index each reading as a new document:
Publishing {"value": 21.5} to sensors/s1/reading indexes one document into readings.

Connection Configuration

OPENSEARCH_CONFIG Parameters

string
required
Server root with scheme and port, for example https://opensearch.example.com:9200. A path is kept, so a reverse-proxy prefix such as https://gateway.example.com/opensearch works. A host without a scheme uses https://.
string
User for basic authentication. It must not contain :. Leave out USERNAME and PASSWORD for a cluster without security.
string
Password for USERNAME. Use GET SECRET. Any character works, including ; = ' @ : / and non-ASCII characters.
boolean
true accepts any server certificate, such as a self-signed one or one for another host name. Use it only in a test setup. Default: false, which checks the certificate against the CAs trusted by the broker host.
integer
Seconds one request may take, from sending it to the end of the answer. A request that takes longer fails. From 1 to 3600. Default: 30.
integer
Seconds to open the TCP and TLS connection. From 1 to 3600. Default: 5.
boolean
Only picks the scheme of a BASE_URL written without one: false uses http://. Leave it out when BASE_URL has a scheme.
Never hardcode credentials in production. Use environment variables and encrypted secrets to keep sensitive values out of your connector definitions:
See Environment Variables & Secrets for setup and usage.

Settings checked at deploy

A connector whose settings cannot work is refused when you deploy it. The message names the setting and never repeats the password. These are refused:
  • A BASE_URL that is not an http:// or https:// URL, or that has a query (?…) or a fragment (#…)
  • A login inside BASE_URL, such as https://user:password@opensearch.example.com:9200. Put it in USERNAME and PASSWORD.
  • USE_SSL false with an https:// BASE_URL, or USE_SSL true with http://
  • A USERNAME that contains :, or a PASSWORD without a USERNAME
  • A boolean that is not true or false, or a timeout that is not a whole number from 1 to 3600
A USERNAME with an empty PASSWORD, for example a GET SECRET that is not set yet, still deploys. Requests then fail with an authentication error.

Credentials

The login is sent as basic authentication (Authorization: Basic, UTF-8) on every request. It never appears in the log, in a connection check reply, or in a status message. API keys, AWS IAM (SigV4) signing, and client certificates are not supported. On Amazon OpenSearch Service, use an internal user of fine-grained access control. Least privilege. The connector needs no cluster permissions. For events and STORE IN, a role with these index permissions on its own indices is enough:

Event Configuration

EVENT Parameters

string
MQTT topic pattern that triggers the event. Supports wildcards. Use SOURCE_TOPIC or EVERY.
string
required
An index request or a search, as a CLEAN or JSON object. See Query format.
string
MQTT topic where the result is published. A + in it takes the matching level of the source topic. Required for an EVERY event.
string
Run the event on a schedule, for example WITH EVERY 1 MINUTE. Use it for searches: an index event on a schedule writes the same document again.

Query format

QUERY is a JSON object, written as CLEAN:{key: value} with unquoted keys and simple values, or as plain JSON with its quotes escaped for the LoT string ("{\"index\": \"readings\", …}"). A query with both index and body indexes a document. Any other query is a search.
Do not wrap a search in body. CLEAN:{index: logs, body: {query: …}} has both index and body, so it stores the query as a document. Put the search options next to index: CLEAN:{index: logs, query: …}.

Index options

Search options

Every key except index is sent as the _search request body, so any search option that OpenSearch accepts works. Only the hits are published. Aggregations (aggs) run, but their results are not published. A search with no match publishes [].

Index names

An event’s index is lowercased, and \ / ? " < > |, spaces, and hyphens become _. So coreflux-events is written to and searched in coreflux_events. Use underscores in event index names. STORE IN only lowercases its WITH TABLE name and keeps hyphens.

Placeholders

Each placeholder goes in as one JSON value, so a payload cannot change the structure of the query, and values are stored as sent:
  • Unquoted (value: {payload.json.value}): a JSON number, true, false, or null keeps its type. A JSON object or array goes in as that JSON. Any other text is stored as a string, with its quotes, apostrophes, commas, braces, and backslashes. Text such as {topic} inside a value is not expanded.
  • Quoted (text: \"{payload}\"): always one JSON string, whatever the payload holds. Quote free text that goes into a search, so a payload is searched for as text.
Dates and other values are stored and returned exactly as sent. A date string such as 2026-01-02T03:04:05.678+02:00 keeps its offset in the document and in search results.
An unquoted placeholder whose value is a JSON object goes into the query as an object, so a publisher can set query options. Quote placeholders that must stay text, and do not build index from a payload. Keep untrusted publishers off the event’s source topic with a rule.

Writing Data

Index each JSON payload with its line and the time it arrived:
Each index request publishes a result to DESTINATION_TOPIC:
Alternative: STORE IN with Models. Instead of writing an index query, bind a model to this connector. Each model update indexes one new document with the model’s fields into the index named by WITH TABLE, plus a UTC timestamp unless the model has a timestamp field. OpenSearch creates the index on first use:
STORE IN keeps the hyphen, so this writes to line-readings. See Data Storage Overview for the full STORE IN workflow.

When a field changes type

OpenSearch builds the index mapping from the first document. If a field later changes type, for example a number becomes text, OpenSearch refuses the documents that do not fit. Each refusal is logged with OpenSearch’s reason, such as mapper_parsing_exception: failed to parse field [count] of type [long]. Use a new index, or reindex.

Reading Data

A search event reads documents on demand. Publish to its SOURCE_TOPIC, and the matching documents are published to DESTINATION_TOPIC as one JSON array:
To run it, publish the text to search for:
The result is the _source of each hit:

Plain JSON queries

Write the query as JSON, with its quotes escaped for the LoT string:

Paging and sorting

Take the range and the page from the payload:

Timed Polling

An EVERY event runs the same search on a schedule:

Query patterns

When an event fails

A request that OpenSearch refuses, such as a bad query, a mapping conflict, 403, or 429, or a request that cannot reach OpenSearch, fails the event. Nothing is published, the error is logged, and the event’s ON ERROR block runs. The error carries OpenSearch’s own type and reason, for example:
The same message is kept as the connector’s last error. A refused STORE IN document is logged the same way. Requests are not retried.

While OpenSearch is unreachable

A request that cannot reach OpenSearch (refused, unreachable, a TLS failure, or no answer within the timeout) marks the connector disconnected. An answer that is an error, such as 400, 403, or 429, leaves it connected, because the server answered. After a connection failure, the next event or STORE IN checks OpenSearch at once. If OpenSearch answers, the work runs. If not, the work is skipped and later checks run at most every 5 seconds. Work that arrives between checks is skipped instead of each request waiting out a timeout. Each check logs how many events and STORE IN documents were skipped: a warning while OpenSearch is still down, and an information line with the total when the connector reconnects. A removed or redeployed connector closes its connections.

Checking the connection

-checkConnectorConnection <Name> sends GET / with the connector’s own settings and login. The check passes when OpenSearch answers, and also on 403: the login was accepted, and the user only lacks cluster permissions, which the connector does not need. The reply names the endpoint (scheme, host, port, and path), never the login. The check waits at most 8 seconds.
A failed check says what to look at: authentication, TLS, a refused connection, an unknown host, or no answer. A timeout says how many seconds it waited: CONNECTION_TIMEOUT while connecting, REQUEST_TIMEOUT once connected.

Troubleshooting

  • Put the scheme and port in BASE_URL, with no login, query, or fragment
  • Move a login from BASE_URL to USERNAME and PASSWORD
  • Remove USE_SSL, or make it match the scheme of BASE_URL
  • Check USERNAME and PASSWORD
  • A GET SECRET that is not set leaves PASSWORD empty, which fails the same way
  • Install the cluster’s CA on the broker host
  • For a self-signed certificate in a test setup, set IGNORE_CERT_ERRORS "true"
  • “Closed the connection” usually means http:// against an HTTPS port, or the reverse. Fix the scheme in BASE_URL.
  • Check that OpenSearch is running and listening on that host and port. Managed services often use port 443.
  • Check that a firewall allows the connection
  • Raise CONNECTION_TIMEOUT for a slow link
  • Grant the user the index permission it needs on that index pattern. See Credentials.
  • Name the index in every search
  • The query has both index and body. Move the search options out of body, next to index.
  • Event index names turn hyphens into _. Use underscores, or STORE IN, which keeps hyphens.
Not supported: update by query, delete, bulk requests, publishing aggregation results, API keys, AWS SigV4 signing, client certificates, and retries.

Next Steps

Data Storage Connectors Overview

Compare all storage options.

CrateDB Connector

Configure CrateDB for time-series data.
Last modified on December 4, 2026