Hi everyone
How to split a single cell with a different number of strings in CVS file into separate cells (fields).
Assign the names of the fields from the string itself. If I manually write the names of the fields and their number(like in the example below), it will work only if all strings are contained in each cell but in reality, the number of strings in a cell is different.
example
Data cvs.file
ID,Name,Category
1,Desk Chair,"Furniture,Hard furnishings,categoryE7E7163,Hendi,"
2,Sofa,"Furniture,Soft furnishings, Bartscher"
input{
file {
path => "E:/test.csv"
start_position => "beginning"
sincedb_path => "NULL"
}
}
filter {
dissect {
mapping => {
"message" => '%{product_id},%{name},"%{category},%{sub_category},%{alt_category},%{brand}"'
# it's okay for id=1 (Desk Chair) but not right for id=2 (Sofa)
}
}
}
output{
elasticsearch {
hosts => "http://localhost:9200"
index => "test_products"
user => "elastic"
password => "**"
}
stdout{}
}
What I need to be stored in ELK
"_source": {
"ID": 1,
"Name": "Desk Chair",
"Category": "Furniture",
"Hard furnishings": "Hard furnishings",
"categoryE7E7163": "categoryE7E7163",
"Hendi": "Hendi",
}
"_source": {
"ID": 2,
"Name": "Sofa",
"Category": "Furniture",
"Soft furnishings": "Soft furnishings",
"categoryE7E7163": "categoryE7E7163",
"Bartscher": "Bartscher",
}