一、多表聯查問題
首先開門見山的說,elasticsearch對多表的聯查是不支持的,暫時只能說支持“過車數據可以打標記”
1.分析案例一
網上有個案例地址爲:
http://www.wowtools.org/blog/articles/2015/09/08/1441692036407.html
截圖如下:
圖中1和2是建立學生和班級關係
圖中3和4是插入數據,注意4的url中明確了parent是c1。
分析如下:這樣使用必須在插入過車數據的時候確定過車的父類(例如:駕駛員男女,年齡),這樣根本滿足不了我們的需求。
2.分析案例二
1) 創建ehlindex4索引並創建表my_type,腳本如下:
curl -XPOST host213:9200/ehlindex4 -d'{
"mappings": {
"my_type": {
"properties": {
"car_number": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}'
2) 添加一個標記字段tag,並添加兩個嵌套字段sex和age
curl -XPOST host213:9200/ehlindex4/my_type/_mapping -d'{
"my_type" : {
"properties" : {
"tag" : {
"properties" : {
"sex":{"type":"string","index": "not_analyzed"},
"age":{"type":"string","index": "not_analyzed"}
}
}
}
}
}'
3) 添加測試數據
curl -XPOST host213:9200/ehlindex4/my_type/2 -d'{
"car_number" : "京ABA110"
}'
4) 使用修改接口追加標記sex和age
curl -XPOST 'host213:9200/ehlindex4/my_type/2/_update' -d '{
"doc" : {
"tag":{
"sex":"男",
"age":"29"
}
}
}'
5) 查詢測試一下
分析如下:這樣可以後臺跑任務添加標記,前臺就可以查詢了。
二、Elasticsearch和hdfs問題
首先說2.2和hdfs的插件根本下載不到匹配的,而且安裝文檔很缺乏。論壇看了一下說,支持數據副本到hdfs。建議等新版本發佈再整。