Prerequisites
- Ensure the OpenSearch cluster is accessible from RisingWave.
- If you are running RisingWave locally from binaries, make sure that you have JDK 11 or later versions installed in your environment.
Create an OpenSearch sink
Use the following syntax to create an OpenSearch sink. Once a sink is created, any insert or update to the sink will be streamed to the specified OpenSearch endpoint.Parameters
Notes about primary keys and OpenSearch IDs
The OpenSearch sink defaults to theupsert sink type. It does not support the append-only sink type.
The OpenSearch sink detects column-level changes during upserts and sends only the modified columns, helping reduce the load on OpenSearch.
To customize your OpenSearch ID, specify it via the primary_key parameter. RisingWave will combine multiple primary key values into a single string with the delimiter set, and use it as the OpenSearch ID.
If you don’t want to customize your OpenSearch ID, RisingWave will use the first column in the sink definition as the OpenSearch ID.
Data type mapping
OpenSearch uses a mechanism called dynamic field mapping to dynamically create fields and determine their types automatically. It treats all integer types as long and all floating-point types as float. To ensure data types in RisingWave are mapped to the data types in OpenSearch correctly, we recommend that you specify the mapping via index templates.
OpenSearch doesn’t require users to explicitly
CREATE TABLE. Instead, it infers the schema on-the-fly based on the first record ingested. For example, if a record contains a jsonb {v1: 100}, v1 will be inferred as a long type. However, if the next record is {v1: "abc"}, the ingestion will fail because "abc" is inferred as a string and the two types are incompatible.
This behavior may lead to missing records. For monitoring, see Grafana, where there is a panel for all sink write errors.