-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sink): support elasticsearch 8 sink (#12269)
- Loading branch information
Showing
14 changed files
with
200 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Demo: Sinking to ElasticSearch | ||
|
||
In this demo, we want to showcase how RisingWave is able to sink data to ElasticSearch. | ||
|
||
1. Set the compose profile accordingly: | ||
Demo with elasticsearch 7: | ||
``` | ||
export COMPOSE_PROFILES=es7 | ||
``` | ||
|
||
Demo with elasticsearch 8 | ||
``` | ||
export COMPOSE_PROFILES=es8 | ||
``` | ||
|
||
2. Launch the cluster: | ||
|
||
```sh | ||
docker-compose up -d | ||
``` | ||
|
||
The cluster contains a RisingWave cluster and its necessary dependencies, a datagen that generates the data, a single-node elasticsearch for sink. | ||
|
||
3. Execute the SQL queries in sequence: | ||
|
||
- create_source.sql | ||
- create_mv.sql | ||
- create_es[7/8]_sink.sql | ||
|
||
4. Check the contents in ES: | ||
|
||
```sh | ||
# Check the document counts | ||
curl -XGET -u elastic:risingwave "http://localhost:9200/test/_count" -H 'Content-Type: application/json' | ||
|
||
# Check the content of a document by user_id | ||
curl -XGET -u elastic:risingwave "http://localhost:9200/test/_search" -H 'Content-Type: application/json' -d '{"query":{"term": {"user_id":2}}' | jq | ||
|
||
# Get the first 10 documents sort by user_id | ||
curl -XGET -u elastic:risingwave "http://localhost:9200/test/_search?size=10" -H 'Content-Type: application/json' -d'{"query":{"match_all":{}}, "sort": ["user_id"]}' | jq | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE SINK bhv_es_sink | ||
FROM | ||
bhv_mv WITH ( | ||
connector = 'elasticsearch', | ||
index = 'test', | ||
url = 'http://elasticsearch8:9200', | ||
username = 'elastic', | ||
password = 'risingwave' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE SINK bhv_es_sink | ||
FROM | ||
bhv_mv WITH ( | ||
connector = 'elasticsearch', | ||
index = 'test', | ||
url = 'http://elasticsearch8:9200', | ||
username = 'elastic', | ||
password = 'risingwave' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE MATERIALIZED VIEW bhv_mv AS | ||
SELECT | ||
user_id, | ||
target_id, | ||
event_timestamp | ||
FROM | ||
user_behaviors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CREATE table user_behaviors ( | ||
user_id int, | ||
target_id VARCHAR, | ||
target_type VARCHAR, | ||
event_timestamp TIMESTAMP, | ||
behavior_type VARCHAR, | ||
parent_target_type VARCHAR, | ||
parent_target_id VARCHAR, | ||
PRIMARY KEY(user_id) | ||
) WITH ( | ||
connector = 'datagen', | ||
fields.user_id.kind = 'sequence', | ||
fields.user_id.start = '1', | ||
fields.user_id.end = '1000', | ||
fields.user_name.kind = 'random', | ||
fields.user_name.length = '10', | ||
datagen.rows.per.second = '10' | ||
) FORMAT PLAIN ENCODE JSON; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
version: "3" | ||
services: | ||
elasticsearch7: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:7.11.0 | ||
environment: | ||
- xpack.security.enabled=true | ||
- discovery.type=single-node | ||
- ELASTIC_PASSWORD=risingwave | ||
ports: | ||
- 9200:9200 | ||
profiles: | ||
- es7 | ||
elasticsearch8: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:8.10.0 | ||
environment: | ||
- xpack.security.enabled=true | ||
- discovery.type=single-node | ||
- ELASTIC_PASSWORD=risingwave | ||
ports: | ||
- 9200:9200 | ||
profiles: | ||
- es8 | ||
compactor-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: compactor-0 | ||
compute-node-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: compute-node-0 | ||
etcd-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: etcd-0 | ||
frontend-node-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: frontend-node-0 | ||
grafana-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: grafana-0 | ||
meta-node-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: meta-node-0 | ||
connector-node: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: connector-node | ||
minio-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: minio-0 | ||
prometheus-0: | ||
extends: | ||
file: ../../docker/docker-compose.yml | ||
service: prometheus-0 | ||
volumes: | ||
compute-node-0: | ||
external: false | ||
etcd-0: | ||
external: false | ||
grafana-0: | ||
external: false | ||
minio-0: | ||
external: false | ||
prometheus-0: | ||
external: false | ||
message_queue: | ||
external: false | ||
name: risingwave-compose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters