使用 ElasticSearch River 搜索 CouchDB
我已经为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" : [ ]
}
I've created a couchDB river (from this elasticsearch example) for elasticsearch with the following code:
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"
}
}'
When I try to search the the couchDB using elasticsearch with this command:
curl -XGET http://localhost:9200/tasks/tasks -d query{"user":"jbattle"}
I get the response:
No handler found for uri [/tasks/tasks] and method [GET][]
I've been searching but have yet to discover a solution to/for this issue.
UPDATE:
I've discovered the proper query is:
curl -XGET 'http://localhost:9200/_river/tasks/_search?q=user:jbattle&pretty=true'
Though, despite no longer receiving an error, I get 0 hits:
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的两个查询都不正确。第一个缺少端点
/_search
,第二个正在查询索引_river
而不是索引tasks
。_river
索引是存储河流而不是数据的位置。配置河流时,您指定了索引tasks
。因此,请尝试以下操作:
或者如果这不起作用,请尝试在
tasks/tasks
中搜索任何文档:clint
Both of your queries are incorrect. The first one is missing the endpoint
/_search
and the second one is querying index_river
instead of indextasks
.The
_river
index is where your river is stored not your data. When you configured your river, you specified indextasks
.So try this instead:
Or if that doesn't work, try searching for any docs in
tasks/tasks
:clint
您发布的示例文件已移至 github。这些人给出了一个不错的演练如何获得沙发和elasticsearch一起工作。
不幸的是,目前接受的答案对我不起作用。但是,如果我将类似的内容粘贴到浏览器的地址栏中,它就会起作用。请注意,url 中只有一个对“tasks”索引的引用,而不是两个。
要进行真正的搜索,您可以尝试这样的操作:
The example file you posted got moved to github. These guys give a decent walkthrough of getting couch and elasticsearch to work together.
Unfortunately, the currently accepted answer doesn't work for me. But if I paste something like this in my browser's address bar it works. Notice that there is only one reference to the "tasks" index in the url, not two.
To do a real search you could try something like this: