How to get data from other index (indexb) and add it to current index (temp) based on common field

I have two indexes:

current one: temp
PUT temp/doc/1
{"Field1" : "data1",
"Field2" : "data2", "cnt_no":"1"}

and other index: indexb
PUT indexb/doc/1
{"Field3" : "data3",
"Field4" : "data4", "cnt_no":"1"}

I would like to create the second index based on index temp but add columns from indexb to it. Common field in cnt_no.

Basically I like to add field Field3 and Field4 from indexb based on cnt_no and create indexc.

I used the following logstash but it doesn't create indexc.

input {
elasticsearch {
hosts => ["http://localhost:9200"]
user => "user1"
password => "pass1"
index => "indexb"
}
}

filter {
elasticsearch {
hosts => ["http://locahost:9200"]
user => "user1"
password => "pass1"
index => "temp"
query => "cnt_no:%{cnt_no}"
fields => {
"Field1" => "Field1"
"Field2" => "Field2"
}
}
}

}
output {
elasticsearch {
hosts => ["http://locahost:9200"]
user => "user1"
password => "pass1"
ssl_certificate_verification => "false"
index => "indexc"
document_id => "%{cnt_no}"
doc_as_upsert => "true"
action => "update"
}
}

I am getting error and indexc is not create. there is something wrong in the filter section.
I need help on the filter section.
How can I do this?

What error?

[ERROR][logstash.agent ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, input, filter, output at line 24, column 1 (byte 515) after ", :backtrace=>["/logstash/compiler.rb:41:in compile_imperative'", "/logstash/compiler.rb:49:in compile_graph'", "/logstash/compiler.rb:11:in block in compile_sources'", "org/jruby/RubyArray.java:2577:in map'", "/logstash/compiler.rb:10:in compile_sources'", "org/logstash/execution/AbstractPipelineExt.java:151:in initialize'", "/logstash/pipeline.rb:22:in initialize'", "/logstash/pipeline.rb:90:in initialize'", "/logstash/pipeline_action/create.rb:43:in block in execute'", "/logstash/agent.rb:96:in block in exclusive'", "org/jruby/ext/thread/Mutex.java:165:in synchronize'", "/logstash/agent.rb:96:in exclusive'", "/logstash/pipeline_action/create.rb:39:in execute'", "/logstash/agent.rb:334:in block in converge_state'"]}

You have an extra } just before the output section that you need to remove.

Thanks a lot!

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