[英]How to set field in Logstash as “not_analyzed” using Logstash config file
我有一個彈性搜索索引,我用它來索引一組文檔。
這些文檔最初是csv格式,我正在使用logstash解析這些文檔。
我的Logstash配置文件是。
input {
file {
path => "/csv_files_for_logstash/app1lg.csv"
type => "core2"
start_position => "beginning"
} }
filter {
csv {
separator => ","
columns=> ["Date","Package Name","App Version Code","Current Device Installs","Daily Device Installs","Daily Device Uninstalls","Daily Device Upgrades","Current User Installs","Total User Installs","Daily User Installs","Daily User Uninstalls"]
}
mutate {convert => ["App Version Code", "string"]}
mutate {convert => ["Current Device Installs", "float"]}
mutate {convert => ["Daily Device Installs", "float"]}
mutate {convert => ["Daily Device Uninstalls", "float"]}
mutate {convert => ["Current User Installs", "float"]}
mutate {convert => ["Total User Installs", "float"]}
mutate {convert => ["Daily User Installs", "float"]}
mutate {convert => ["Daily User Uninstalls", "float"]}
ruby {
code => '
b = event["App Version Code"]
string2=""
for counter in (3..(b.size-1))
if counter == 4
string2+= "."+ b[counter]
elsif counter == 6
string2+= "("+b[counter]
elsif counter == 8
string2+= b[counter] + ")"
else
string2+= b[counter]
end
end
event["App Version Code"] = string2
'
}
}
output {
elasticsearch {
embedded => true
action => "index"
host => "es"
index => "fivetry"
workers => 1
}
stdout{
codec => rubydebug {
}
}
}
現在我的字段值(應用版本代碼)在csv中看起來像“123456789”,我使用Ruby代碼解析為“4.56(789)”。
此術語將其分為不同的值,因為這不是分析。
我知道還有其他方法來創建映射並將其設置為not_ananlysed,但我不知道如何制作,所以,
有沒有辦法只用我的logstash配置文件設置這個not_analysed?
也,
在Kibana中沒有.raw字段,我可以使用確切的字符串。
感謝致敬,
您無法通過Logstash配置設置映射。 映射與Logstash無關,只與Elasticsearch有關。
在插入這些文檔之前,您需要在Elasticsearch中預先映射這些字段,您可以創建索引,然后使用映射API來設置映射,或者您可以使用索引模板來執行此操作,這樣您就可以創建映射而不是最初創建索引。
Logstash提供了用於新索引的默認模板。 您可以編輯此文件,但這不是一個好主意(它會在升級時被覆蓋等)。
elasticsearch {}輸出允許您指定自己使用的模板而不是默認模板。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.