我正在使用jdbc river
进行elasticsearch来从MySQL获取批量数据。
curl -XPUT 'localhost:9200/_river/company_river/_meta' -d '{
"type": "jdbc",
"jdbc": {
"driver": "com.mysql.jdbc.Driver",
"url": "jdbc:mysql://localhost:3306/dbname",
"user": "username",
"password": "password",
"sql": "select id as _id, name, date, code, status from tablename",
"strategy": "simple",
"poll": "2s"
},
"index": {
"index": "jdbc",
"type": "jdbc",
"versioning": true,
"digesting": true,
"bulk_size": 160,
"max_bulk_requests": 5
}
}'
执行上面的命令时,它不会从MySQL获取所有数据。表包含超过100M条记录。