es head插件
git clone https://github.com/mobz/elasticsearch-head.git
npm install
npm run start
ELK 启动
e:
E:\WWW\elasticsearch-6.2.3\bin
elasticsearch.bat
E:\WWW\elasticsearch-6.2.3\elasticsearch-head
npm run start
E:\WWW\kibana-6.2.3-windows-x86_64\kibana-6.2.3-windows-x86_64\bin
kibana.bat
E:\WWW\filebeat-6.2.3-windows-x86_64
filebeat.exe -e -c filebeat.yml
E:\WWW\logstash-6.2.3\bin
bin\logstash.bat -f config\mysql.yml
logstash 增量 全量同步mysql到es
input {
jdbc {
jdbc_driver_library => "E:\\WWW\\logstash-6.2.3\\mysql-connector-java-5.1.47.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://127.0.0.1:3306/xbp_pro?useUnicode=true&characterEncoding=utf-8&useSSL=false"
jdbc_user => "root"
jdbc_password => "root"
clean_run => true
schedule => "* * * * *"
statement => "SELECT * FROM ad_audit_user WHERE utime > :sql_last_value AND utime < NOW() ORDER BY utime desc"
}
}
output {
elasticsearch {
hosts => ["127.0.0.1:9200"]
index => "ad_audit_user"
document_id => "%{id}"
}
}
es 查询语句练习
{
"mappings": {
"novel": {
"properties": {
"publish_date": {
"format": "yyy-MM-dd||yyyy-MM-dd HH:mm:ss||epoch_millis",
"type": "date"
},
"author": {
"type": "keyword"
},
"title": {
"type": "text"
},
"word_count": {
"type": "integer"
}
}
}
}
}
{
"publish_date": "2010-9-8",
"author": "张三",
"title": "菜谱",
"word_count": 80
}
{
"query": {
"match_all": {}
},
"from": 1,
"size": 1
}
{
"query": {
"match_all": {}
}
}
{
"query": {
"match": {
"title": "elasticsearch"
}
},
"sort": {
"publish_date": {
"order": "desc"
}
}
}
聚合查询
{
"query": {
"match_phrase": {
"title": "elasticsearch高阶"
}
},
"sort": {
"publish_date": {
"order": "desc"
}
}
}
{
"query": {
"multi_match": {
"query": "张三",
"fields": [
"author",
"title"
]
}
}
}
{
"query": {
"query_string": {
"query": "(张三 AND 菜谱) OR 九阳神功",
"fields": [
"title",
"aurhor"
]
}
}
}
http://localhost:9200/book/_search
{
"query": {
"bool": {
"filter": {
"term": {
"word_count": 80
}
}
}
}
}
{
"query": {
"bool": {
"must": [
{
"match": {
"title": "elasticsearch"
}
},
{
"match": {
"author": "李四"
}
}
]
}
}
}
{
"query": {
"bool": {
"should": [
{
"match": {
"title": "elasticsearch"
}
},
{
"match": {
"author": "李四"
}
}
]
}
}
}
{
"query": {
"bool": {
"filter": {
"term": {
"title": "elasticsearch"
}
}
}
}
}
match 模糊匹配
match_phrase 完全匹配
multi_match 多字段匹配
filter 过滤两种
(query filter )
字段匹配
{
"query": {
"term": {
"author": "张三"
}
}
}
范围匹配
{
"query": {
"range": {
"word_count": {
"gte": 70,
"lte": 200
}
}
}
}
GET _search
{
"query": {
"match_all": {}
}
}
POST _analyze
{
"analyzer":"standard",
"text": "我是中国人"
}
POST _analyze
{
"analyzer":"ik_smart",
"text": "我是中国人"
}
POST _analyze
{
"analyzer":"ik_max_word",
"text": "我是中国人"
}
GET _cat/indices