CREATE TABLE tableName(
colName colType,
bb INT
)WITH(
type ='elasticsearch7',
address ='ip:port[,ip:port]',
index ='index',
id = 'field[,field]',
authMesh = 'true',
userName = 'userName',
password = 'password',
parallelism ='1'
)
CREATE TABLE MyTable(
channel varchar,
pv int,
)WITH(
type ='kafka11',
bootstrapServers ='172.16.8.107:9092',
zookeeperQuorum ='172.16.8.107:2181/kafka',
offsetReset ='latest',
topic ='es_test',
timezone='Asia/Shanghai',
updateMode ='append',
enableKeyPartitions ='false',
topicIsPattern ='false',
parallelism ='1'
);
CREATE TABLE MyResult(
channel varchar,
pv int
)WITH(
type ='elasticsearch7',
address ='172.16.8.193:9200',
authMesh='true',
username='elastic',
password='abc123',
estype ='external',
cluster ='docker-cluster',
index ='myresult',
-- index = '{pv}' # 动态索引写法
id ='pv',
parallelism ='1'
);
CREATE TABLE sideTable(
a varchar,
b varchar,
PRIMARY KEY(a) ,
PERIOD FOR SYSTEM_TIME
)WITH(
type ='elasticsearch7',
address ='172.16.8.193:9200',
index ='sidetest',
authMesh='true',
username='elastic',
password='abc123',
cache ='LRU',
cacheSize ='10000',
cacheTTLMs ='60000',
partitionedJoin ='false',
parallelism ='1'
);
insert
into
MyResult
select
w.b as pv,
s.channel as channel
from
MyTable s
join
sideTable w
on s.pv = w.a
where
w.a = '10'
and s.channel='xc';
{"channel":"xc26","pv":10,"xctime":1232312}
http://localhost:9200/myresult/_search
{"_index":"myresult","_type":"external","_id":"8aX_DHIBn3B7OBuqFl-i","_score":1.0,"_source":{"pv":"10","channel":"xc26"}}