我所用的是kibana的插件git
地址:http:localhost:9200/_plugin/kopf/#!/indexTemplatesapp
顯示畫面:url
template 是你想定義的index namespa
示例我定義的一些mapping的模板插件
代碼:code
{ "order": 0, "template": "test-*", "settings": { "index": { "number_of_replicas": "1", "number_of_shards": "3", "refresh_interval": "1s" } }, "mappings": { "_default_": { "dynamic_templates": [ { "page_url_field": { "mapping": { "index": "analyzed", "omit_norms": true, "fielddata": { "format": "disabled" }, "type": "string", "fields": { "raw": { "index": "not_analyzed", "ignore_above": 512, "doc_values": true, "type": "string" } } }, "match": "page_url", "match_mapping_type": "string" } }, { "useragent_field": { "mapping": { "index": "analyzed", "omit_norms": true, "fielddata": { "format": "disabled" }, "type": "string", "fields": { "raw": { "index": "not_analyzed", "ignore_above": 512, "doc_values": true, "type": "string" } } }, "match": "useragent", "match_mapping_type": "string" } }, { "page_referrer_field": { "mapping": { "index": "analyzed", "omit_norms": true, "fielddata": { "format": "disabled" }, "type": "string", "fields": { "raw": { "index": "not_analyzed", "ignore_above": 512, "doc_values": true, "type": "string" } } }, "match": "page_referrer", "match_mapping_type": "string" } }, { "string_fields": { "mapping": { "index": "not_analyzed", "ignore_above": 10240, "doc_values": true, "type": "string" }, "match": "*", "match_mapping_type": "string" } }, { "float_fields": { "mapping": { "doc_values": true, "type": "float" }, "match": "*", "match_mapping_type": "float" } }, { "geolocation_fields": { "mapping": { "index": "not_analyzed", "type": "geo_point" }, "match": "geolocation" } }, { "loanAmount_fields": { "mapping": { "index": "not_analyzed", "type": "double" }, "match": "loanAmount" } }, { "collector_date_fields": { "mapping": { "index": "not_analyzed", "type": "string" }, "match": "collector1_date" } }, { "collector_time_fields": { "mapping": { "index": "not_analyzed", "format": "HH:mm:ss.SSS", "type": "date" }, "match": "collector_time" } }, { "double_fields": { "mapping": { "doc_values": true, "type": "double" }, "match": "*", "match_mapping_type": "double" } }, { "byte_fields": { "mapping": { "doc_values": true, "type": "byte" }, "match": "*", "match_mapping_type": "byte" } }, { "short_fields": { "mapping": { "doc_values": true, "type": "short" }, "match": "*", "match_mapping_type": "short" } }, { "integer_fields": { "mapping": { "doc_values": true, "type": "integer" }, "match": "*", "match_mapping_type": "integer" } }, { "long_fields": { "mapping": { "doc_values": true, "type": "long" }, "match": "*", "match_mapping_type": "long" } }, { "date_fields": { "mapping": { "doc_values": true, "type": "date" }, "match": "*", "match_mapping_type": "date" } }, { "geo_point_fields": { "mapping": { "doc_values": true, "type": "geo_point" }, "match": "*", "match_mapping_type": "geo_point" } } ], "properties": { "@timestamp": { "doc_values": true, "type": "date" }, "collector_tstamp": { "type": "string" }, "geo_location": { "type": "geo_point" }, "geoip": { "dynamic": true, "properties": { "location": { "doc_values": true, "type": "geo_point" }, "longitude": { "doc_values": true, "type": "float" }, "latitude": { "doc_values": true, "type": "float" }, "ip": { "doc_values": true, "type": "ip" } }, "type": "object" }, "@version": { "index": "not_analyzed", "doc_values": true, "type": "string" } }, "_all": { "enabled": false, "omit_norms": true } } }, "aliases": {} }
refresh_interval 若是想用spark實時查找es的話,這個參數最好是設置比spark batch時間小一些。否則查出來的數據錯誤orm
index 能夠設置爲not_analyzed 表示不分詞 ,也能夠設置爲analyzed 表示分詞,因爲業務的需求,我這邊沒有設置分詞xml