我想将数据从csv文件加载到弹性搜索索引中。我没有使用eleasticsearch gem(还),只是一个简单的ruby脚本。这是:
CSV.open("candidates.csv", "r").each do |row|
#file = "candidates.csv"
#file_data = file.read
#csv_rows = CSV.parse(file_data, headers: true, header_converters: :symbol)
#csv_rows.each do |row|
curl -XPOST "http://localhost:9200/candidates/candidate" -d '
{
"first" => row[:first],
"last" => row[:last],
"designation" => row[:designation],
"company" => row[:company],
"city" => row[:city],
"country" => row[:country],
"email" => row[:email],
"phone" => row[:phone],
"experience" => row[:experience]
}'
错误消息是:
load.rb:6: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
这种做法是完全错误的,即在红宝石脚本中间插入“卷曲”请求?
这样做的最佳方法是什么,以及如何才能做到最好?
非常感谢。