【问题标题】:Search CouchDB Using ElasticSearch River使用 ElasticSearch River 搜索 CouchDB
【发布时间】:2011-12-08 03:01:01
【问题描述】:

我使用以下代码为 elasticsearch 创建了一条 couchDB 河(来自 elasticsearch example):

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 elasticsearch


    【解决方案1】:

    您的两个查询都不正确。第一个缺少端点/_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'
    

    克林特

    【讨论】:

    • 谢谢。你的回答很到位。现在,我需要研究如何为这些字段编制索引。再次感谢!
    【解决方案2】:

    The example file 您发布的内容已移至 github。这些人给了a decent walkthrough 让沙发和弹性搜索一起工作。

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

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-06
      • 1970-01-01
      相关资源
      最近更新 更多