AgileWorksOrg / elasticsearch-river-csv

CSV river for ElasticSearch
Apache License 2.0
91 stars 45 forks source link

How do I add multiple CSV files? #37

Closed shyamalee93 closed 10 years ago

shyamalee93 commented 10 years ago

I want to add multiple CSV files as different indices. How do I do it if all the csv files are present in the same /root/csv folder path? How do I add multiple CSV files to the same index as different types?

flicker581 commented 10 years ago

I think you need to setup multiple CSV river instances with different indexes, types and filename patterns (filename_pattern).

shyamalee93 commented 10 years ago

Oh, okay. I won't be able to add different CSV files as different types for a given index?

flicker581 commented 10 years ago

You can do it. Simply create two rivers pointing to the same index. Two rivers cannot point to the same files, but having identical types or pointing to the same index (you case) is allowed.

shyamalee93 commented 10 years ago

That is great, okay. When I try to creat a single index with the following code :

curl -XPUT localhost:9200/_river/my_csv_river/_meta -d ' { "type" : "csv", "csv_file" : { "folder" : "/root/csv", "filename_pattern" : ".*.csv$", "fields" : [ "Title", "Tracking", "Timeline", "% Awareness", “Timeline_Num” ], "first_line_is_header" : "true", "field_separator" : ",", "field_id" : "Timeline", }, "index" : { "index" : "awareness", "type" : "csv_type", "bulk_size" : 100, "bulk_threshold" : 10 } }'

I get the following error :

{"error":"MapperParsingException[failed to parse]; nested: JsonParseException[Invalid UTF-8 start byte 0x80\n at [Source: [B@193ad24; line: 12, column: 7]]; ","status":400}

I wanted to try creating two rivers pointing to the same index like you had mentioned. I'm sorry, I'm new to Elasticsearch and programming as such so any help would be appreciated. I keep getting the parsing exception, failed to parse error whenever I change a few properties/ add or remove lines in the cURL request.

shyamalee93 commented 10 years ago
vtajzich commented 10 years ago

if you want to import CSV files you don't have to specify filename_pattern at all. When you want to specify it you have to escape \, see readme where an example is shown.

vtajzich commented 10 years ago

@shyamalee93 could you, please, share some of the files you're trying to upload to ES? as well as the both requests?

vtajzich commented 10 years ago

@shyamalee93 any update?