首页 > 其他分享 >Doris整合Elasticsearch

Doris整合Elasticsearch

时间:2023-06-30 11:25:52浏览次数:37  
标签:index title 数据源 Doris doris Elasticsearch es 整合 ES

1、环境

doris 1.2.4
Elasticsearch 7.7 安装教程 https://www.cnblogs.com/yanzhong/p/17515917.html

2、doris 配置外表(方法一)

1、添加语法

详细 官网
https://doris.apache.org/zh-CN/docs/1.2/lakehouse/external-table/es?_highlight=外表#doris中创建es外表

CREATE EXTERNAL TABLE `es_table`
ENGINE=Elasticsearch 
PROPERTIES (
"hosts" = "http://192.168.31.128:9200",   -- es 集群地址
"index" = "phone",
                        -- es 索引名称
"user" = "elastic",
                       -- 账号密码
"password" = "162552"
                    
);
参数 说明
hostsES 集群地址,可以是一个或多个,也可以是ES前端的负载均衡地址
index 对应的ES的index名字,支持alias,如果使用doc_value,需要使用真实的名称
type index的type,ES 7.x及以后的版本不传此参数
user ES集群用户名
password 对应用户的密码信息
  • ES 7.x之前的集群请注意在建表的时候选择正确的索引类型type
    • 认证方式目前仅支持Http Basic认证,并且需要确保该用户有访问: /_cluster/state/、_nodes/http等路径和index的读权限; 集群未开启安全认证,用户名和密码不需要设置
    • Doris表中的列名需要和ES中的字段名完全匹配,字段类型应该保持一致
    • ENGINE必须是 Elasticsearch

2、操作

支持查询

selec * from es_table

不支持增 删 改

INSERT INTO es_table VALUES ("http://www.xxx.com/xx.jpg","mate40",888,"华为")
update es_table SET title = "123" where title = "手机666"
DELETE FROM es_table where title = "手机666"



3、doris catalog 多数据源 es(方法二)

1、添加语法

Elasticsearch Catalog 除了支持自动映射 ES 元数据外,也可以利用 Doris 的分布式查询规划能力和ES(Elasticsearch) 的全文检索能力相结合,提供更完善的 OLAP 分析场景解决方案:

  • ES 中的多 index 分布式 Join 查询。
  • Doris 和 ES 中的表联合查询,更复杂的全文检索过滤。
  • 使用限制支持 Elasticsearch 5.x 及以上版本。

详情 官网

https://doris.apache.org/zh-CN/docs/1.2/lakehouse/multi-catalog/es

CREATE CATALOG es PROPERTIES (
    "type"="es",
    "hosts"="http://192.168.31.128:9200",
     "user" = "elastic",
    "password" = "162552"
);

参数说明​

| 参数| 是否必须| 默认值| 说明|
| ------------ | ------------ |
| hosts| 是| | ES 地址,可以是一个或多个,也可以是 ES 的负载均衡地址|
| user| 否| 空| ES 用户名|
| password| 否| 空| 对应用户的密码信息|
|doc_value_scan| 否| true| 是否开启通过 ES/Lucene 列式存储获取查询字段的值|
|keyword_sniff|否|true|是否对 ES 中字符串分词类型text.fields 进行探测,通过 keyword 进行查询。设置为 false 会按照分词后的内容匹配|
|nodes_discovery|否|true|是否开启 ES 节点发现,默认为 true,在网络隔离环境下设置为 false,只连接指定节点|
|ssl|否|false|ES 是否开启 https 访问模式,目前在 fe/be 实现方式为信任所有|
|mapping_es_id|否|false|是否映射 ES 索引中的_id字段|
|like_push_down|否|true|是否将 like 转化为 wildchard 下推到 ES,会增加 ES cpu 消耗|

  • 认证方式目前仅支持 Http Basic 认证,并且需要确保该用户有访问: /_cluster/state/、_nodes/http 等路径和 index 的读权限; 集群未开启安全认证,用户名和密码不需要设置。
  • 5.x 和 6.x 中一个 index 中的多个 type 默认取第一个。

2、操作

查看所有的catalog 数据源
#  internal  是doris 主数据源 
show catalogs;

  • 切换到es的catlog数据源
  • 因为 Elasticsearch 没有 Database 的概念,所以连接 ES 后,会自动生成一个唯一的 Database:default_db。
  • 并且在通过 SWITCH 命令切换到 ES Catalog 后,会自动切换到 default_db。无需再执行 USE default_db 命令。
#切换 数据源
switch es;
#查询所有的表(对应es中的index索引)
show tables

查询

select * from phone;

增删改 (不支持)

提示es 的catalog 没有这些操作 需要切换到doris的 数据源下

INSERT INTO phone VALUES ("http://www.xxx.com/xx.jpg","mate40",888,"华为")
update phone SET title = "123" where title = "手机666"
DELETE FROM es_table where title = "手机666"



切换到doris 数据源下 提示 没有对应的库跟表

#切换数据源
switch internal;
#操作
INSERT INTO es.phone VALUES ("http://www.xxx.com/xx.jpg","mate40",888,"华为")

update es.phone SET title = "123" where title = "手机666"

DELETE FROM es.phone where title = "手机666"



标签:index,title,数据源,Doris,doris,Elasticsearch,es,整合,ES
From: https://www.cnblogs.com/yanzhong/p/17516118.html

相关文章

  • Elasticsearch安装
    安装Elasticsearch1、拉取镜像dockerpullelasticsearch:7.7.02、启动dockerrun--nameelasticsearch-d-eES_JAVA_OPTS="-Xms512m-Xmx512m"-e"discovery.type=single-node"-p9200:9200-p9300:9300elasticsearch:7.7.0--name表示容器名称-d:后台运行......
  • Doris 1.2.0 JDBC外表 及 Mutil Catalog
    环境doris需要版本1.2以上jar包根据不同的数据源需要不同的jar包https://mvnrepository.com/a.MySQLmysql-connector-java-5.1.47.jarb.PostgreSQLpostgresql-42.5.1.jarc.Oracleojdbc8.jard.Clickhouseclickhouse-jdbc-0.3.2-patch11......
  • 29.ElasticSearch分词
    两种查询方式这两种方式的结果都是一样的,实际使用中我们都是使用第二种方式。在将所有的检索条件全部放在url里GET/bank/_search?q=*&sort=account_number:asc表示在banK索引下查询所有文档根据account_number正序 hits里有10条数据,总数是1000,可以看出ES默认做了分页......
  • SpringBoot整合 Camunda 流程引擎
    目录1整合Camunda流程引擎1.1简介1.1.1概念介绍1.1.2组件介绍1.2Springboot集成1.2.1pom.xml1.2.2配置文件1.2.3数据库1.2.4登录界面1.3绘制流程图1.3.1下载安装1.3.2绘制1.3.2.1任务分类1.3.2.2网关1.3.2.3指定key1.3.3集成在idea中1.3.4引入项目测试1整合......
  • springboot整合mybatis
    1,在application.yml中配置点击查看代码#mybatis#配置mapper路径mybatis:mapper-locations:classpath:mapper/*.xml2,在每个DAO接口上面追加@Mapper注解-------------------------------------------------------------增删改查的实现代码application.yml配......
  • 四、SpringBoot整合Apollo
    Apollo非常支持与Spring和SpringBoot的整合。这里选择SpringBoot2.7.9,java选择jdk17。添加依赖:<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency>......
  • 2、Elasticsearch单节点安装脚本
    #!/bin/bashES_VERSION=7.17.5UBUNTU_URL="https://mirrors.tuna.tsinghua.edu.cn/elasticstack/7.x/apt/pool/main/e/elasticsearch/elasticsearch-${ES_VERSION}-amd64.deb"RHEL_URL="https://mirrors.tuna.tsinghua.edu.cn/elasticstack/7.x/yum/${ES......
  • 3、Elasticsearch集群安装脚本
    #!/bin/bashES_VERSION=7.17.5UBUNTU_URL="https://mirrors.tuna.tsinghua.edu.cn/elasticstack/7.x/apt/pool/main/e/elasticsearch/elasticsearch-${ES_VERSION}-amd64.deb"RHEL_URL="https://mirrors.tuna.tsinghua.edu.cn/elasticstack/7.x/yum/${ES_......
  • 4、Elasticsearch插件Head和Serebro实现Elasticsearch的图形化管理
    Elasticsearch访问Elasticsearch支持各种语言使用RESTfulAPI通过端口9200与之进行通信,可以用你习惯的web客户端访问Elasticsearch可以用三种方式和Elasticsearch进行交互curl命令和其它浏览器:基于命令行,操作不方便插件:在node节点上安装head,Cerebro等插件,实现图形操......
  • Spring ElasticSearch Date
    问题背景使用spring-data-elasticsearch:4.4.12查询数据,数据映射到对象的时候时间字段格式异常,报错如下对象和Es通过@document注解进行映射,对象中有一个时间字段@Field(type=FieldType.Date,format={},pattern=DatePattern.CHINESE_DATE_PATTERN)privateDat......