? ? ? 上面呢催烘,我們說(shuō)了,elk的安裝事情缎罢,接下來(lái)呢伊群,我們就要正式的去學(xué)習(xí)elk,深入的了解elk的內(nèi)部使用手冊(cè)屁使,也就是dsl語(yǔ)句了在岂,一個(gè)功能不亞于sql,但比sql還要復(fù)雜的東西蛮寂!
? ? ? 一般情況下呢蔽午,我們都是使用http協(xié)議看來(lái)與es來(lái)完成交互。我們會(huì)使用json字符串的格式數(shù)據(jù)來(lái)完成這個(gè)操作酬蹋,無(wú)論是數(shù)據(jù)的操作及老,還是索引的操作啊,還是映射的改變范抓,都是我們通過(guò)這部分來(lái)完成的骄恶。 而我們將這個(gè)json封裝好的對(duì)象便成為DSL語(yǔ)句。 簡(jiǎn)單點(diǎn)就是類似于sql 語(yǔ)句一樣匕垫,不過(guò)沒(méi)有sql語(yǔ)句那么詳細(xì)的劃分 什么ddl僧鲁,dcl,dml 一類的象泵。 這邊統(tǒng)一一點(diǎn)就是DSL語(yǔ)句寞秃。 可以分為查詢語(yǔ)句啊,創(chuàng)建語(yǔ)句啊偶惠,什么的春寿。
?這里呢,我先展示一下
{
"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"
]
}
}
上面這個(gè)呢忽孽,就是我們教程中所使用的的索引結(jié)構(gòu)绑改!
接下來(lái)呢,我們說(shuō)這個(gè)簡(jiǎn)單查詢兄一,也就是trem查詢厘线,
{"query":{
"term":{
"_id": "2018-02-05B00TA7TM1W"
}
}
}
我們查詢一個(gè)_id 是?2018-02-05B00TA7TM1W 的數(shù)據(jù)。
結(jié)果集瘾腰,如下
{
"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
}
}
]
}
}
經(jīng)本人測(cè)試皆的,數(shù)字類型啊,float類型啊蹋盆,還有字符串都是可以使用的费薄。
備注:
term呢硝全,叫做簡(jiǎn)單查詢, 是指楞抡,在指定字段中具有給定單詞的文檔伟众。(備注:term 查詢是不被解析的,因此需要你精準(zhǔn)的提供查詢內(nèi)容)
新手小白一個(gè)召廷,歡迎大佬斧正5氏帷!竞慢!