How to use index template file?


(kikuchan) #1

I created the index template file, but it could not apply to the Elasticsearch.
I put the index template file to the $/home/config/templates/japanese_template.json
When I create the index by the logstash which used output plugin "elasticsearch", the index template file could not apply to the index.
could you please let me know What is wrong.

following contents are the index template file.

・index template file

{
"japanese_template":{
"template":"",
"settings":{
"analysis":{
"filter":{
"pos_filter":{
"type":"kuromoji_part_of_speech",
"stoptags":[
"助詞-格助詞-一般",
"助詞-終助詞"
]
},
"greek_lowercase_filter":{
"type":"lowercase",
"language":"greek"
}
},
"tokenizer":{
"kuromoji":{
"type":"kuromoji_tokenizer"
},
"ngram_tokenizer":{
"type":"nGram",
"min_gram":"2",
"max_gram":"3",
"token_chars":[
"letter",
"digit"
]
}
},
"analyzer":{
"kuromoji_analyzer":{
"type":"custom",
"tokenizer":"kuromoji",
"filter":[
"kuromoji_baseform",
"pos_filter",
"greek_lowercase_filter",
"cjk_width"
]
},
"ngram_analyzer":{
"tokenizer":"ngram_tokenizer"
}
}
}
},
"mappings" : {
"default":{
"dynamic_templates":[
{
"string_template":{
"mapping":{
"index":"not_analyzed",
"type":"string"
},
"match_mapping_type":"string",
"match":"
"
}
}
],
"properties":{
"KJ_ID":{
"type":"integer"
},
"TITLE":{
"type":"string",
"store":"yes",
"index":"analyzed",
"analyzer":"kuromoji_analyzer"
},
"USER_ID":{
"type":"multi_field",
"fields":{
"no_analyzed":{
"index":"not_analyzed",
"type":"string"
},
"analyzed":{
"index":"analyzed",
"type":"string"
}
}
},
"REGIST_DATE_TIME":{
"type":"multi_field",
"fields":{
"no_analyzed":{
"index":"not_analyzed",
"type":"string"
},
"analyzed":{
"index":"analyzed",
"type":"string"
}
}
},
"UPDATE_DATE_TIME":{
"type":"date",
"store":"yes",
"format":"yyyy-MM-dd hh:mm:ss"
},
"UPDATE_FLG":{
"type":"boolean"
}
}
}
}
}
}

and I used the following logstash's config file.

・config file

input {
file {
path => "C:\elastic\logstash-1.5.3\conf\test1.csv"
type => "Kiji"
start_position => "beginning"
}
}

filter {
csv {
columns => ["KJ_ID","TITLE","USER_ID","REGIST_DATE_TIME","UPDATE_DATE_TIME","UPDATE_FLG"]
separator => ","
}
}
output
{
elasticsearch{
action => "index"
host => "localhost"
index => "test1"
protocol => "transport"
cluster => "clustername"
}
}

If you have a solution, please help me.

sincerely


(Tuan Trieu) #2

The output configuration of Logstash should be:

elasticsearch {
      host => [ 'your_es_ip ' ]
      manage_template => false
      template => 'path_to_your_index_template'
}

(kikuchan) #3

@tuantm
thanks for comment.

I modified the config file, but it didn't apply to index.
all columns type became the "string"

・config file

input {
file {
path => "C:\elastic\logstash-1.5.3\conf\test1.csv"
type => "Kiji"
start_position => "beginning"
}
}

filter {
csv {
columns => ["KJ_ID","TITLE","USER_ID","REGIST_DATE_TIME","UPDATE_DATE_TIME","UPDATE_FLG"]
separator => ","
}
}
output
{
elasticsearch{
action => "index"
host => [ "XXX.XXX.XXX.XXX"]
manage_template => false
template => "C:\home\config\template\japanse_template.json"
template_name => "japanese_template"
index => "test1"
protocol => "transport"
cluster => "clustername"
}
}

why can't I do?


(Mark Walkom) #4

Is that the exact file you are using, cause it doesn't look right.


(kikuchan) #5

@tuantm
@warkolm

thanks for your comments.
I reviewed the index template file and modified it, so I could use the index template file.

thank you for helping me!!

sincerely.


(system) #6