上面呢,我们说了,elk的安装事情,接下来呢,我们就要正式的去学习elk,深入的了解elk的内部使用手册,也就是dsl语句了,一个功能不亚于sql,但比sql还要复杂的东西!
一般情况下呢,我们都是使用http协议看来与es来完成交互。我们会使用json字符串的格式数据来完成这个操作,无论是数据的操作,还是索引的操作啊,还是映射的改变,都是我们通过这部分来完成的。 而我们将这个json封装好的对象便成为DSL语句。 简单点就是类似于sql 语句一样,不过没有sql语句那么详细的划分 什么ddl,dcl,dml 一类的。 这边统一一点就是DSL语句。 可以分为查询语句啊,创建语句啊,什么的。
这里呢,我先展示一下
{
"state": "open",
"settings": {
"index": {
"creation_date": "1521612181858",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "xn_EqFYYSjOoAXa8TnhJnA",
"version": {
"created": "5040099"
},
"provided_name": "amazon"
}
},
"mappings": {
"ware": {
"properties": {
"date": {
"type": "long"
},
"catPath2Rank": {
"type": "long"
},
"rootPath": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"catPath1": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"catPath2": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"postTime": {
"type": "long"
},
"qaNum": {
"type": "long"
},
"reviewCnt": {
"type": "long"
},
"price": {
"type": "float"
},
"ratings": {
"type": "float"
},
"catPath1Rank": {
"type": "long"
},
"asin": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"id": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"prices": {
"type": "float"
},
"brand": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"rootPathRank": {
"type": "long"
}
}
}
},
"aliases": [ ],
"primary_terms": {
"0": 12,
"1": 12,
"2": 12,
"3": 14,
"4": 12
},
"in_sync_allocations": {
"0": [
"Ro7cRV7GTKqiflfYRui-wA"
],
"1": [
"8g_uJHN7R_6pWhmmuPPiXQ"
],
"2": [
"90ZYF-_2TLmIaC8aDjCleQ"
],
"3": [
"TESb5gkHRGCf-rVuBbDwdA"
],
"4": [
"RWPLEnifQQqGLdNaR4wY4A"
]
}
}
上面这个呢,就是我们教程中所使用的的索引结构!
接下来呢,我们说这个简单查询,也就是trem查询,
{"query":{
"term":{
"_id": "2018-02-05B00TA7TM1W"
}
}
}
我们查询一个_id 是 2018-02-05B00TA7TM1W 的数据。
结果集,如下
{
"took": 49,
"timed_out": false,
"_shards": {
"total": 10,
"successful": 10,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "amazon",
"_type": "ware",
"_id": "2018-02-05B00TA7TM1W",
"_score": 1,
"_source": {
"asin": "B00TA7TM1W",
"brand": "General Motors",
"catPath1": "Automotive>Replacement Parts>Brake System>Pin Links>Retainer Keys",
"catPath1Rank": 4,
"date": 1517760000000,
"postTime": 1442764800000,
"prices": 2.88,
"rootPath": "Automotive",
"rootPathRank": 508299
}
}
]
}
}
经本人测试,数字类型啊,float类型啊,还有字符串都是可以使用的。
备注:
term呢,叫做简单查询, 是指,在指定字段中具有给定单词的文档。(备注:term 查询是不被解析的,因此需要你精准的提供查询内容)
新手小白一个,欢迎大佬斧正!!!