elasticsearch2.2多表聯查分析及其hdsf支持說明

一、多表聯查問題

首先開門見山的說,elasticsearch對多表的聯查是不支持的,暫時只能說支持“過車數據可以打標記

1.分析案例一

網上有個案例地址爲:

http://www.wowtools.org/blog/articles/2015/09/08/1441692036407.html

截圖如下:

 

圖中12是建立學生和班級關係

圖中34是插入數據,注意4url中明確了parentc1

分析如下:這樣使用必須在插入過車數據的時候確定過車的父類(例如:駕駛員男女,年齡),這樣根本滿足不了我們的需求。

 

2.分析案例二

 

1)  創建ehlindex4索引並創建表my_type,腳本如下:

curl -XPOST host213:9200/ehlindex4 -d'{
  "mappings": {
    "my_type": { 
      "properties": {
        "car_number": {
          "type": "string",
          "index": "not_analyzed"
        }
          }
        }
      }
    }
  }
}'

 

2) 添加一個標記字段tag,並添加兩個嵌套字段sexage

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) 使用修改接口追加標記sexage

 

curl -XPOST 'host213:9200/ehlindex4/my_type/2/_update' -d '{
"doc" : {
"tag":{
"sex":"男",
"age":"29"
}
}
}'

5) 查詢測試一下

 

分析如下:這樣可以後臺跑任務添加標記,前臺就可以查詢了。

 

二、Elasticsearchhdfs問題

首先說2.2hdfs的插件根本下載不到匹配的,而且安裝文檔很缺乏。論壇看了一下說,支持數據副本到hdfs。建議等新版本發佈再整。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章