1. ES倒排索引
给每个词指定编号,记录热词所在的文档编号
ES底层分词就是这种格式
数据库使用的是B-tree的结构
正排索引:通过key找value
倒排索引:通过value找key
2. ES 9200与9300的区别
9200是与外部通信的接口,支持restful web接口,http协议
9300是ES内部,分布式节点,高可用节点间通信的接口,TCP协议
3. 高级检索
GET、PUT,/索引/类型/_serarch?age>10&&age<21
4. DSL,检索term 与,match的区别
发送post请求,请求格式使用json格式
term是精确匹配
match是模糊匹配。
filter是对搜索结果进行过滤
“_source”:[ "X", "Y"] 指定显示搜索结果的那些字段
搜索时必须使用“query”关键字
5. IK中文分词插件
ES自带的是标准分词器,但是对中文的支持不友好,总是被中分按照每次字去拆分。
IK-smart,支持中文,并且会去网上查找热词。
6. 自定义热词
在plus/conf/目录下创建自定义文件,添加自定义热词,然后让插件加载此文件
7. luence, 分词搜索引擎工具包
是个开源的工具包
8. text与keyword的区别
text类型支持分词
keyword类型是不支持分词的
9. ES是分布式多用户的搜索引擎
10. ES的架构设计
gateway-->luence dir-->river、mapping、search 、index--->discover 、script -->transport--->restful api
11. ES的设计原理
核心是index
从下向index: 爬取内容-->构建文档-->分析文档-->索引文档-->索引
从上向index: 用户查询接口--->构建 query-->运行query
12. mapping
文档结构映射,动态映射,静态映射
动态映射:会根据数据自定义mapping, 将整形指定为long类型
静态映射:在添加数据前,先构建表结构
13. ELK
elasticsearch,---存储,查询,
logstash --- 数据转储
kibana --- 可视化工具
14. 幂等操作
同一操作不管重复几次,结果都是一样的。
15. POST与PUT
POST是作用在组合之上
curl http://localhost:9200/usr/ -d '{"age":20, "name":"小军"}'
PUT是作用在具体资源
curl http://localhost:9200/usr/1 -d '{"age":20, "name":"小蓝"}'
查询
16. pretty作用
es可以得到易于识别的json结果
17._source字段可以指定要显示的字段
root@RealEyeServerITS:~# curl -XGET 'http://localhost:9200/testes/user/1?_source=age&pretty'| jq .
{
"_index" : "testes",
"_type" : "user",
"_id" : "1",
"_version" : 4,
"found" : true,
"_source" : {
"age" : 20
}
}
18. 查询指定类型的所有数据
curl -XGET 'http://localhost:9200/testes/user/_search' | jq .
19. 指定查询条件
curl -XGET 'http://localhost:9200/testes/user/_search?q=age:20' | jq .
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 1,
"hits": [
{
"_index": "testes",
"_type": "user",
"_id": "AXFDbuNbamoZeUigoHG7",
"_score": 1,
"_source": {
"age": 20,
"name": "小军"
}
},
{
"_index": "testes",
"_type": "user",
"_id": "1",
"_score": 1,
"_source": {
"age": 20,
"name": "小军"
}
}
]
}
}
DSL查询
1. _mget可以查询多个文件
使用数组设置查询条件
2. ids的使用
如果在同一索引,同一类型中
3. XHEAD查找文档是否存在
root@RealEyeServerITS:~# curl -i -XHEAD http://localhost:9200/testes/user/1?pretty
Warning: Setting custom HTTP method to HEAD with -X/--request may not work the
Warning: way you want. Consider using -I/--head instead.
HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
content-length: 156
更新
1. _update
将旧数据改为删除状态,插入新数据,后台删除旧数据
curl -XPOST http://localhost:9200/testes/user/1/_update -d '{"doc":{"age":12, "name":"xiaohong"}}'
批量操作_bulk
可以将数据写入json文件 ,http最大请求内容100mb
2. 查看集群状态
curl -XGET http://localhost:9200/_cluster/health?pretty
3. 分片数量
分布式搜索提高性能和吞吐量
4. gateway
索引的持久化方式
5. discovery
es节点自动发现节点方式,广播方式,多播协议
6. transport(核心)
内部节点交互方式。通过tcp的http协议,还有其他方式(插件)
7. 主版本,此版本
8.词分析过程
空格分析器-->词分割器-->大写变小写-->index
9. 停用词
分析文档过程中,把“的,着,了”这些词认为是停用词。