How to make dynamic document id from name of the json file

I'm nooby when it's come to elasticsearch what i'm trying to do is, while indexing the large json file want to give it a document id same with file's name
dummy.json
document_id => "dummy" kinda

<
input {
file {
path => "/home/abahadir/Desktop/Proje/searchflask/elasticsearch/*.json"
start_position => "beginning"
sincedb_path => "/dev/null"
codec => multiline { pattern => "^}" negate => true what => next auto_flush_interval => 1 }
}
}
output {
elasticsearch {
hosts => "http://localhost:9200"
index => "restaurants"
document_type => "docket"
}
stdout{ codec => rubydebug }
}
/>

if anyone can help i will be greatefull

The file input will add a [path] field to events that contains the filename. You can reference that in the elasticsearch output using

document_id => "%{[path]}"

Is the %{[path]} gives the full path or just the file name ?

The full path. If you just want the filename part then you can extract it by copying path to another field and using mutate+gsub on that.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.