使用 ElasticSearch River 搜索 CouchDB

发布于 2024-12-09 23:34:19 字数 1123 浏览 0 评论 0原文

我已经为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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

话少情深 2024-12-16 23:34:19

您的两个查询都不正确。第一个缺少端点 /_search,第二个正在查询索引 _river 而不是索引 tasks

_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'

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 index tasks.

The _river index is where your river is stored not your data. When you configured your river, you specified index tasks.

So try this instead:

curl -XGET 'http://localhost:9200/tasks/tasks/_search?q=user:jbattle&pretty=true'

Or if that doesn't work, try searching for any docs in tasks/tasks:

curl -XGET 'http://localhost:9200/tasks/tasks/_search?q=*&pretty=true'

clint

娇柔作态 2024-12-16 23:34:19

您发布的示例文件已移至 github。这些人给出了一个不错的演练如何获得沙发和elasticsearch一起工作。

不幸的是,目前接受的答案对我不起作用。但是,如果我将类似的内容粘贴到浏览器的地址栏中,它就会起作用。请注意,url 中只有一个对“tasks”索引的引用,而不是两个。

http://localhost:9200/tasks/_search?pretty=true

要进行真正的搜索,您可以尝试这样的操作:

http://localhost:9200/tasks/_search?q="hello"&pretty=true

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.

http://localhost:9200/tasks/_search?pretty=true

To do a real search you could try something like this:

http://localhost:9200/tasks/_search?q="hello"&pretty=true
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文