我正在尝试学习弹性搜索并将其连接到 MySQL 数据库。如果我自己使用elasticsearch,一切正常,但是当尝试从数据库中获取数据时,由于某种原因它似乎不起作用。我是弹性搜索和使用 jdbc 的河流的真正新手,所以我真的无法比这更明确地描述我的问题。
为了创建一条河流,我使用了以下命令:
curl -XPUT 'localhost:9200/customertest/customer/_meta' -d '{
"type" : "jdbc",
"jdbc" : {
"url" : "jdbc:mysql://localhost:3306/database",
"user" : "root",
"password" : "root",
"sql" : "select * from customers"
}
}'
运行时:
curl -XGET 'localhost:9200/customertest/_search?pretty&q=*'
我得到以下答案:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "customertest",
"_type" : "customer",
"_id" : "_meta",
"_score" : 1.0,
"_source":{
"type" : "jdbc",
"jdbc" : {
"url" : "jdbc:mysql://localhost:3306/database",
"user" : "root",
"password" : "root",
"sql" : "select * from customers"
}
}
} ]
}
}
任何想法?