(Elasticsearch)实战Elasticseartch、Logstash、Kibana

1、Elasticsearch的堆栈内存设置建议

9967595-3292925868e93be0.png
image.png

2、elasticsearch.yml设置中文分词器:
/usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.4/elasticsearch-analysis-ik-6.5.4.zip
//安装完,在elasticsearch.yml中添加配置
index.analysis.analyzer.default.type: ik
3、关闭elasticsearch
curl -XPOST http://localhost:9200/_cluster/nodes/_shutdown
9967595-597bda51ab5a749b.png
image.png

9967595-a061dc15af281ff0.png
image.png

4、监控客户端状态的插件head;
http://localhost:9200/_plugin/head
9967595-131208ff47feb219.png
image.png

5、Marvel 图形化监控客户端
http://lcalhost:9200/_plugin/marvel/
9967595-25df51a52e04978d.png
image.png

6、Health 查看集群状态
9967595-1eb5aac0ef86fb76.png
image.png

7、架构
9967595-6d2fa8ae7f585f40.png
image.png

8、 http://ip:9200/index/type/id
index: dbname
type: dbtable
GET/POST/PUT/DELETE
?pretty 增强可读性
9、mapping 映像,相当于数据类型
10、搜索参数:_search?q=location:Shanghai
11、实例
创建索引文件test,用PUT方法创建
创建mapping文件,//不是elasticsearch的注释,mapping相当于对象
9967595-55727fa8223cb779.png
image.png

9967595-bc980c2df4e27a14.png
image.png

创建检索表达式
9967595-7487ac7ff86320af.png
image.png

9967595-6978ac7e171f65db.png
image.png

9967595-f580887a3130364c.png
image.png

9967595-c1f0933acefca159.png
image.png

9967595-33acde1ea5017486.png
image.png

12、用XPUT方式创建索引
9967595-396f732ecbf51a0e.png
image.png

用_settings修改索引
9967595-2afd3c96a10ea243.png
image.png

索引属性:number_of_replicas 索引的副本数量
blocks.read_only 只读 blocks.read 禁止读取 blocks.write blocks.metadata
调取索引的配置:curl -XGET http://ip:port/weibo/_settings
http://xx/weibo1,weibo2/_settings
_all/_settings 所有索引
mar*/_settings
13、插入数据
9967595-857cc25c2c233cf4.png
image.png

String,Integer,Long,Float,Double,Boolean,Null,Date
14、_stats 索引状态
9967595-f7e9099392bb797a.png
image.png

9967595-ab0c6cb6e6ca5a6c.png
image.png

15、配置mapping
PUT /{index}/_mapping/{type}
PUT /index/type/_mapping -d '{
"wb":{
"properties": {
"mymessage":{
"type":"String",
"store": true
}
}
}
}'
获取get /index/_mapping/type
_all/_mapping
获取索引某个字段 get /index/_mapping/type/field/user

删除DELETE
16、打开关闭索引文件
curl -XPOST /myindex/_open
curl -XPOST /myindex/_close
检索 curl -XHEAD /myindex -v
XDELETE
清空索引缓存 curl -XPOST /myindex/_cache/clear
刷新索引数据 curl -XPOST /myindex/_refresh
优化索引数据 curl -XPOST /myindex/_optimize
flush /myindex/_flush
给索引配置分析器


9967595-e17aeeda8f953a70.png
image.png

临时使用分词器


9967595-3b4dfdef9a5b8c85.png
image.png

获取文档指定信息
9967595-3f0830339931d127.png
image.png

?pretty&fields=user 只显示user字段
9967595-3f7407712179b1a7.png
image.png

删除 curl -XDELETE ///
数据更新 xput
9967595-c5badaeee2c6d85e.png
image.png

9967595-e5a34cb4cb634e3c.png
image.png

9967595-513e0267eef33b66.png
image.png

9967595-d533ce540d148778.png
image.png

xpost + _mget? 批量获取


9967595-3716270a3e9d6bf0.png
image.png

_source 获取数据
_query?q=user:xxx


信息检索:curl -XGET ip/_search?q=hello&pretty=true
terms查询:不作分词
match_all:{} 查询所有
常规查询:+ - query query_string


9967595-2503d0f845501c75.png
image.png

prefix


9967595-5d5c1368c91ea974.png
image.png

range
9967595-57575441092fff7b.png
image.png

9967595-2914a29fccd85f3a.png
image.png

more_like_this
9967595-3cf8dc7c36722859.png
image.png

9967595-b843018f256b0c54.png
image.png

fuzzy_like_this


9967595-e8db1afca5ac2b2b.png
image.png

9967595-500669a62590a570.png
image.png

multi_match 多字段检索
9967595-0544bcdac4c2fcdb.png
image.png

/////////////////////////////////////////////////////////////////////
query+filter
9967595-32e556a90ab8bcad.png
image.png

9967595-4b32a74fdcf4ccd1.png
image.png

9967595-1107c1eb64e0cfea.png
image.png

9967595-6410b5890860d5e4.png
image.png

exists
9967595-eadadd97ec1d4439.png
image.png

missing
9967595-55205c9cbcb37509.png
image.png

9967595-55f947d9b6369d79.png
image.png

match_all


9967595-42b29db90b7ea6dc.png
image.png

9967595-f8a2dedc9ee7dc2a.png
image.png

9967595-4b75d6f0840f1206.png
image.png

/////////////////
sort排序 missing:_last 空值放最后


9967595-58fb3cd57b5cb68b.png
image.png

9967595-b234b622d20734d4.png
image.png

facets 统计
terms facets 统计


9967595-d125e8e6a9d6d60f.png
image.png

多字段统计


9967595-2c46f293ec72d9da.png
image.png

排除:exclude
9967595-b3392849c42bc0ea.png
image.png

regex
9967595-8ef7710658b104a6.png
image.png

script放脚本


9967595-9f11f1810d488b6a.png

--
range facets
9967595-22d9156faf551237.png
image.png

9967595-17ea23610238dc0f.png
image.png

histogram facets
9967595-c17023a683769ae0.png
image.png

9967595-e41c5057e273e5e9.png
image.png

date_histogram facets 日期统计
9967595-66888d5e747da17e.png
image.png

9967595-e3342a01b1300e1d.png
image.png

statistical 数字类型统计


9967595-3b3dd2e05884a7b2.png
image.png

terms_stats
9967595-980d17072773514f.png
image.png

//
aggregations 是facets的升级版
9967595-fb0ac0489d843e46.png
image.png

9967595-954b7bf09cf9df75.png
image.png

9967595-12d5d7550ac728b6.png
image.png

9967595-5a39069bd8c6b831.png
image.png

9967595-4467eaf5ce9b5c91.png
image.png

9967595-eade062592694ae0.png
image.png

9967595-ea2b3c488c8de338.png
image.png

9967595-f009c59fc0487c5c.png
image.png

date_range
histogram
date_histogram
missing

猜你喜欢

转载自blog.csdn.net/weixin_34248118/article/details/87458041