2

我使用以下代码为elasticsearch创建了一个couchDB河(来自这个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" : [ ]
}
4

2 回答 2

1

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

_river索引是存储河流的位置,而不是存储数据的位置。当你配置你的河流时,你指定了 index 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'

克林特

于 2011-10-15T10:18:17.747 回答
0

您发布的示例文件已移至 github。这些家伙给出了一个不错的演练,让沙发和弹性搜索一起工作。

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

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

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

http://localhost:9200/tasks/_search?q="hello"&pretty=true
于 2013-04-23T19:30:50.087 回答