Hlastic到Elasticsearch到Kibana:可用字段列中没有字段

时间:2016-03-19 15:08:57

标签: elasticsearch kibana-4

我遵循以下步骤:

Step 1:
create table tutorials_tbl(submission_date date, tutorial_id INT,tutorial_title STRING,tutorial_author STRING) ROW FORMAT SERDE 'com.cloudera.hive.serde.JSONSerDe';

Step 2:
INSERT INTO tutorials_tbl (submission_date, tutorial_title, tutorial_author) VALUES ('2016-03-19 18:00:00', "Mark Smith", "John Paul");

Step 3:
CREATE EXTERNAL TABLE tutorials_tbl_es(submission_date date,tutorial_id INT,tutorial_title STRING,tutorial_author STRING)STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' TBLPROPERTIES('es.resource'='tutor/tutors','es.nodes'='saturn:9200');

Step 4:
INSERT INTO tutorials_tbl_es SELECT * FROM tutorials_tbl LIMIT 1;

Now I selected the index in Kibana>Settings. I have configured _timestamp in the advanced settings so i only got that in the Time-field name even though I have submission_date column in the data.

查询1:为什么我没有在时间字段名称中获取submission_date?

查询2:当我选择_timestamp并点击“创建”时,我在“发现”标签中的“可用”字段下没有得到任何内容?为什么会这样?

1 个答案:

答案 0 :(得分:1)

请将数据加载到tutorials_tbl并尝试以下步骤。

第1步:使用设置和映射创建“tutor”动态模板。

{ 
  "order": 0,
  "template": "tutor-*",
  "settings": {
  "index": {
    "number_of_shards": "4",
    "number_of_replicas": "1",
    "refresh_interval": "30s"
    }
  },
"mappings": {

"tutors": {
"dynamic": "true",
"_all": {
"enabled": true
},
"_timestamp": {
"enabled": true,
"format": "yyyy-MM-dd HH:mm:ss"
},
"dynamic_templates": [
{
"disable_string_index": {

"mapping": {
"index": "not_analyzed",
"type": "string"
},
"match_mapping_type": "string",
"match": "*"
}

}
],
"date_detection": false,
"properties": {
"submission_date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"tutorial_id": {
"index": "not_analyzed",
"type": "integer"
},
"tutorial_title": {
"index": "not_analyzed",
"type": "string"
},
"tutorial_author": {
"index": "not_analyzed",
"type": "string"
}
}
}
}
}

步骤2:根据tutor- *模板创建ES索引“tutor”(来自步骤1)。

我通常使用elasticsearch head“索引”标签/“任何请求”来创建它。

步骤3:使用时间戳映射创建ES HIVE表

CREATE EXTERNAL TABLE tutorials_tbl_es(submission_date STRING ,tutorial_id INT,tutorial_title STRING,tutorial_author STRING)
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'   TBLPROPERTIES('es.resource'='tutor/tutors','es.nodes'='saturn:9200','es.mapping.timestamp'='submission_date');

第4步:将tutorials_tbl中的数据插入tutorials_tbl_es

INSERT INTO tutorials_tbl_es SELECT * FROM tutorials_tbl LIMIT 1;