Kibana:Kibana is a window into the Elastic Stack. It enables visual exploration and real-time analysis of your data in Elasticsearch
Elasticsearch |
Mysql |
Index(索引) |
数据库 |
Type(类型) |
表 |
Documents(文档) |
行 |
Fields |
列 |
倒排索引源于实际应用中需要根据属性的值来查找记录。这种索引表中的每一项都包括一个属性值和具有该属性值的各记录的地址。由于不是由记录来确定属性值,而是由属性值来确定记录的位置,因而称为倒排索引(inverted index)。带有倒排索引的文件我们称为倒排索引文件,简称倒排文件(inverted file)。
1 PUT lagou 2 { 3 “settings”: { 4 “index”: { 5 “number_of_shards”: 5, 6 “number_of_replicas”:1 7 } 8 } 9 }
1 GET lagou/_settings 2 GET _all/_settings 3 GET _settings
1 PUT lagou/_settings 2 { 3 “number_of_replicas”:2 4 }
1 GET _all 2 GET lagou
1 PUT lagou/job/1 --可以不指明id(不指明id,需用POST提交) 2 { 3 "title":"python分布式爬虫开发", 4 "salary_min":15000, 5 "city":"北京", 6 "company":{ 7 "name":"百度", 8 "company_addr":"北京市软件园" 9 }, 10 "publish_date":"2017-4-16", 11 "comments":15 12 }
1 GET lagou/job/1 2 GET lagou/job/1?_source=title 3 GET lagou/job/1?_source=title,city
1 PUT lagou/job/1 2 { 3 Xxx:yyy 4 }
1 POST lagou/job/1/_update 2 { 3 "doc":{ 4 "comments":100 5 } 6 }
1 DELETE lagou/job/1
1 POST lagou/job/_delete_by_query?conflicts=proceed 2 { 3 "query": { 4 "match_all": {} 5 } 6 }
1 DELETE lagou
1 GET _mget 2 { 3 "docs":[ 4 { 5 "_index":"testdb", 6 "_type":"job1", 7 "_id":1 8 }, 9 { 10 "_index":"testdb", 11 "_type":"job2", 12 "_id":2 13 } 14 ] 15 }
或者
1 GET testdb/_mget 2 { 3 "docs":[ 4 { 5 "_type":"job1", 6 "_id":1 7 }, 8 { 9 "_type":"job2", 10 "_id":2 11 } 12 ] 13 }
或者
1 GET testdb/job1/_mget 2 { 3 "docs":[ 4 { 5 "_id":1 6 }, 7 { 8 "_id":2 9 } 10 ] 11 }
或者
1 GET testdb/job1/_mget 2 { 3 "ids":[1,2] 4 }
1 action_and_meta_data\n 2 optional_source\n 3 action_and_meta_data\n 4 optional_source\n 5 ... 6 action_and_meta_data\n 7 optional_source\n
1 {"index":{"_index":"test1", "_type":"type1", "_id":1}} 2 {"field1":"value1", ...} 3 4 {"delete":{"_index":"test1", "_type":"type1", "_id":2}} 5 6 {"create":{"_index":"test1", "_type":"type1", "_id":1}} 7 {"field1":"value1", ...} 8 9 {"update":{"_index":"test1", "_type":"type1", "_id":1}} 10 {"doc":{"field1":"value1"}}
1 POST _bulk 2 {"index":{"_index":"lagou", "_type":"job", "_id":1}} 3 {"title":"python分布式爬虫开发", "salary_min":15000, "city":"北京", "company":{"name":"百度", "company_addr":"北京市软件园"}, "publish_date":"2017-4-16", "comments":15} 4 {"index":{"_index":"lagou", "_type":"job", "_id":2}} 5 {"title":"python django开发", "salary_min":30000, "city":"上海", "company":{"name":"腾讯", "company_addr":"北京市软件园4-1"}, "publish_date":"2017-4-17", "comments":30}
创建索引的时候,可以预先定义字段的类型以及相关属性,mapping是类似于数据库中的表结构定义,主要作用如下:
作用:会让索引建立得更加细致和完善
类型:静态映射和动态映射
内置类型:
常用属性:
属性 | 描述 | 适合类型 |
store |
Yes:存储,no:不存储,默认no |
all |
index |
yes:分析,no:不分析,默认值为true |
string |
null_value |
如果字段为空,可以设置一个默认值,比如“NA” |
all |
analyzer |
可以设置索引和搜索时用的分析器,默认使用的是standard分析器,还可以使用whitespace、simple、english |
all |
include_in_all |
默认es为每个文档定义一个特殊域_all,它的作用是让每个字段被搜索到,,如果不想某个字段被搜索到,可以设置为false |
all |
format |
时间格式字符串的模式 |
date |
1 PUT zhilian 2 { 3 "mappings": { 4 "job":{ 5 "properties": { 6 "title":{ 7 "type":"text" 8 }, 9 "salary_min":{ 10 "type":"integer" 11 }, 12 "city":{ 13 "type":"keyword" 14 }, 15 "company":{ 16 "properties": { 17 "name":{ 18 "type":"text" 19 }, 20 "company_addr":{ 21 "type":"text" 22 }, 23 "employee_count":{ 24 "type":"integer" 25 } 26 } 27 }, 28 "publish_date":{ 29 "type":"date", 30 "format": "yyyy-MM-dd" 31 }, 32 "comments":{ 33 "type": "integer" 34 } 35 } 36 } 37 } 38 }
1 GET zhilian/job/_mapping
原文:https://www.cnblogs.com/dowi/p/10097002.html