我已经为elasticsearch创建了一个couchDB river(来自这个elasticsearch示例),代码如下:
curl -XPUT 'localhost:9200/_river/tasks/_meta' -d '{
"type" : "couchdb",
"couchdb" : {
"host" : "localhost",
"port" : 5984,
"db" : "tasks",
"filter" : null
},
"index" : {
"index" : "tasks",
"type" : "tasks",
"bulk_size" : "100",
"bulk_timeout" : "10ms"
}
}'
当我尝试使用以下命令使用elasticsearch搜索couchDB时:
curl -XGET http://localhost:9200/tasks/tasks -d query{"user":"jbattle"}
我得到了响应:没有找到uri [/tasks/tasks]和方法[GET][]的处理程序
我一直在寻找,但还没有找到解决这个问题的方法。
更新:
我发现正确的查询是:
curl -XGET 'http://localhost:9200/_river/tasks/_search?q=user:jbattle&pretty=true'
虽然,尽管不再收到错误,我得到0命中:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
你的两个查询都不正确。第一个缺少端点/_search
,第二个查询索引_river
而不是索引tasks
。
_river
指数是你的河流存储的地方,而不是你的数据。当您配置river时,您指定了索引tasks
。
那么试试这个:
curl -XGET 'http://localhost:9200/tasks/tasks/_search?q=user:jbattle&pretty=true'
或者,如果不工作,尝试搜索任何文档在tasks/tasks
:
curl -XGET 'http://localhost:9200/tasks/tasks/_search?q=*&pretty=true'
克林特
您发布的示例文件被移动到github。这些家伙给出了一个很好的让couch和elasticsearch一起工作的过程。
不幸的是,目前公认的答案对我不起作用。但如果我把这样的东西粘贴到浏览器的地址栏,它就能工作了。注意,在url中只有一个对"tasks"索引的引用,而不是两个。
http://localhost:9200/tasks/_search?pretty=true
要做一个真正的搜索,你可以尝试这样做:
http://localhost:9200/tasks/_search?q="hello"&pretty=true