wutiangan commented on a change in pull request #3867: URL: https://github.com/apache/incubator-doris/pull/3867#discussion_r440107314
########## File path: docs/zh-CN/extending-doris/doris-on-es.md ########## @@ -30,72 +30,320 @@ Doris-On-ES将Doris的分布式查询规划能力和ES(Elasticsearch)的全文 1. ES中的多index分布式Join查询 2. Doris和ES中的表联合查询,更复杂的全文检索过滤 - 3. ES keyword类型字段的聚合查询:适用于index 频繁发生变化、单个分片文档数量千万级以上且该字段基数(cardinality)非常大 本文档主要介绍该功能的实现原理、使用方式等。 ## 名词解释 -* FE:Frontend,Doris 的前端节点。负责元数据管理和请求接入。 -* BE:Backend,Doris 的后端节点。负责查询执行和数据存储。 -* Elasticsearch(ES):目前最流行的开源分布式搜索引擎。 -* DataNode:ES的数据存储与计算节点。 -* MasterNode:ES的Master节点,管理元数据、节点、数据分布等。 -* scroll:ES内置的数据集游标特性,用来对数据进行流式扫描和过滤。 +### Doirs相关 +* FE:Frontend,Doris 的前端节点,负责元数据管理和请求接入 +* BE:Backend,Doris 的后端节点,负责查询执行和数据存储 +### ES相关 +* DataNode:ES的数据存储与计算节点 +* MasterNode:ES的Master节点,管理元数据、节点、数据分布等 +* scroll:ES内置的数据集游标特性,用来对数据进行流式扫描和过滤 +* _source: 导入时传入的原始JSON格式文档内容 +* doc_values: ES/Lucene 中字段的列式存储定义 +* keyword: 字符串类型字段,ES/Lucene不会对文本内容进行分词处理 +* text: 字符串类型字段,ES/Lucene会对文本内容进行分词处理,分词器需要用户指定,默认为standard英文分词器 -## 如何使用 -### 创建外表 +## 使用方法 + +### 创建ES索引 ``` -CREATE EXTERNAL TABLE `es_table` ( - `id` bigint(20) COMMENT "", +PUT test +{ + "settings": { + "index": { + "number_of_shards": "1", + "number_of_replicas": "0" + } + }, + "mappings": { + "doc": { // ES 7.x版本之后创建索引时不需要指定type,会有一个默认且唯一的`_doc` type + "properties": { + "k1": { + "type": "long" + }, + "k2": { + "type": "date" + }, + "k3": { + "type": "keyword" + }, + "k4": { + "type": "text", + "analyzer": "standard" + }, + "k5": { + "type": "float" + } + } + } + } +} +``` + +### ES索引导入数据 + +``` +POST /_bulk +{"index":{"_index":"test","_type":"doc"}} +{ "k1" : 100, "k2": "2020-01-01", "k3": "Trying out Elasticsearch", "k4": "Trying out Elasticsearch", "k5": 10.0} +{"index":{"_index":"test","_type":"doc"}} +{ "k1" : 100, "k2": "2020-01-01", "k3": "Trying out Doris", "k4": "Trying out Doris", "k5": 10.0} +{"index":{"_index":"test","_type":"doc"}} +{ "k1" : 100, "k2": "2020-01-01", "k3": "Doris On ES", "k4": "Doris On ES", "k5": 10.0} +{"index":{"_index":"test","_type":"doc"}} +{ "k1" : 100, "k2": "2020-01-01", "k3": "Doris", "k4": "Doris", "k5": 10.0} +{"index":{"_index":"test","_type":"doc"}} +{ "k1" : 100, "k2": "2020-01-01", "k3": "ES", "k4": "ES", "k5": 10.0} +``` + +### Doris中创建ES外表 + +``` +CREATE EXTERNAL TABLE `test` ( + `k1` bigint(20) COMMENT "", + `k2` datetime COMMENT "", + `k3` varchar(20) COMMENT "", + `k4` varchar(100) COMMENT "", + `k5` float COMMENT "" +) ENGINE=ELASTICSEARCH // ENGINE必须是Elasticsearch +PROPERTIES ( +"hosts" = "http://192.168.0.1:8200,http://192.168.0.2:8200", +"index" = "test”, +"type" = "doc", + +"user" = "root", +"password" = "root" +); +``` + +参数说明: + +参数 | 说明 +---|--- +**hosts** | ES集群地址,可以是一个或多个,也可以是ES前端的负载均衡地址 +**index** | 对应的ES的index名字 +**type** | index的type,不指定的情况会使用_doc +**user** | ES集群用户名 +**password** | 对应用户的密码信息 + +* ES 7.x之前的集群请注意在建表的时候选择正确的**索引类型type** +* 认证方式仅支持Http Bastic认证,完全开源的ES集群用户和密码不需要指定,需要确保该用户有访问: /\_cluster/state/、\_nodes/http等路径权限和对index的读权限 Review comment: "完全开源的ES集群用户和密码不需要指定" This sentence doesn't read smoothly ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org