Documents are not getting updated but are getting newly created instead of updating the document.
COMPANY_ID is a unique column..
SAMPLE DATA
COMPANY_NAME,LOGO_EXT,COMPANY_ID
ABC LIMITED,JPG,ABC000001
XYZ LIMITED,PNG,ABC000002
AAA LLC,,ABC000003
I am able to create the index and the documents.
The problem is when I update the index the document is getting created instead of getting updated. E.g. BEFORE ABC LIMITED,JPG,ABC000001
AFTER ABCD LIMITED,JPG,ABC000001
So therefor only COMPANY_NAME should be updated.
1. Successfully able to create the index using the below code :-
BAT FILE
cd C:\logstash-7.3.1\bin logstash -f C:\logstash.conf
C:\logstash.conf FILE
input {
jdbc {
jdbc_driver_library => "C:\sqljdbc_7.4\enu\mssql-jdbc-7.4.1.jre8.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://;user=;password=;"
jdbc_user => ""
jdbc_password => ""
statement => "SELECT COMPANY_NAME,LOGO_EXT,COMPANY_ID from dbo.CompanyMaster WITH(NOLOCK) ORDER BY COMPANY_NAME"
}
}
filter {}
output {
stdout {
codec => json_lines
}
elasticsearch {
hosts => "http://localhost:9200"
index => "companylistindex"
document_id => "%{COMPANY_ID}"
action => index
}
}
2. Update code
input {
jdbc {
jdbc_driver_library => "C:\sqljdbc_7.4\enu\mssql-jdbc-7.4.1.jre8.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://;user=;password=;"
jdbc_user => ""
jdbc_password => ""
statement => "SELECT COMPANY_NAME,LOGO_EXT,COMPANY_ID from dbo.CompanyMaster WITH(NOLOCK) WHERE ModifiedOn>'2019-11-01'"
}
}
filter {}
output {
stdout {
codec => json_lines
}
elasticsearch {
hosts => "http://localhost:9200"
index => "companylistindex"
document_id => "%{COMPANY_ID}"
}
}
Please help me update the document.
Note : Only COMPANY_NAME or LOGO_EXT needs to be updated if different. COMPANY_ID is unique column.