ElasticSearch 在使用 LogStash 建立索引时分配自己的 ID
ElasticSearch assign own IDs while indexing with LogStash
我正在为大量信息编制索引,并且我有一个我知道是唯一的字符串键。我想避免使用搜索,而是通过这个人工标识符访问文档。
由于 Path 指令在 ES 1.5 中已停用,有人知道解决此问题的方法吗!?
我的数据如下:
{unique-string},val1, val2, val3...
{unique-string2},val4, val5, val6...
我正在使用 logstash 为文件编制索引,并且更愿意通过 direct get 而不是通过完全匹配来获取文档。
在您的 elasticsearch
输出插件中,只需指定 document_id
设置并引用您要用作 ID 的字段,即 1
在您的 csv
过滤器。
input {
file {...}
}
filter {
csv{
columns=>["1","2","3"]
separator => ","
}
}
output {
elasticsearch {
action => "index"
host => "localhost"
port => "9200"
index => "index-name"
document_id => "%{1}" <--- add this line
workers => 2
cluster => "elasticsearch-cluster"
protocol => "http"
}
}
我正在为大量信息编制索引,并且我有一个我知道是唯一的字符串键。我想避免使用搜索,而是通过这个人工标识符访问文档。
由于 Path 指令在 ES 1.5 中已停用,有人知道解决此问题的方法吗!?
我的数据如下:
{unique-string},val1, val2, val3...
{unique-string2},val4, val5, val6...
我正在使用 logstash 为文件编制索引,并且更愿意通过 direct get 而不是通过完全匹配来获取文档。
在您的 elasticsearch
输出插件中,只需指定 document_id
设置并引用您要用作 ID 的字段,即 1
在您的 csv
过滤器。
input {
file {...}
}
filter {
csv{
columns=>["1","2","3"]
separator => ","
}
}
output {
elasticsearch {
action => "index"
host => "localhost"
port => "9200"
index => "index-name"
document_id => "%{1}" <--- add this line
workers => 2
cluster => "elasticsearch-cluster"
protocol => "http"
}
}