首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何借助elasticsearch插件从elasticsearch服务器索引couchdb,从而获得JSON数据

如何借助elasticsearch插件从elasticsearch服务器索引couchdb,从而获得JSON数据
EN

Stack Overflow用户
提问于 2015-02-09 18:58:24
回答 1查看 1.6K关注 0票数 3

我正在研究数据的图形表示。图形接受JSON数据,因此我需要从couchdb中获取所需的数据。我使用elasticsearch服务器对couchdb进行索引,从而检索所需的数据。我使用elasticsearch插件将couchdb和elasticsearch服务器放在一起。

我已经创建了CouchDB数据库'testdb‘,并为此创建了一些测试文档。使用数据库设置elasticsearch。在通过编写带有默认搜索条件的CURl GET命令进行测试时,我们必须获得超过0的“总命中”,而“hits”必须对搜索的标准具有一定的响应值。但是我们得到了0的“总点击量”和“点击量”:i.e. null

程序我遵循了.

1)下载并安装了couchdb最新版本的

2)验证CouchDB正在运行

卷曲寄主:5984

代码语言:javascript
复制
I got response that starts with:

{"couchdb":"Welcome"...

3)下载的ElasticSearch和安装的服务

service.bat安装 卷曲http://127.0.0.1:9200

代码语言:javascript
复制
I got response as


{ "ok" : true, "status" : 200,..... 

4)为ElasticSearch 1.4.2安装了CouchDB河插件

插件elasticsearch/elasticsearch-river-couchdb/2.4.1 -install

5)创建CouchDB数据库和ElasticSearch索引

curl -X放"http://127.0.0.1:5984/testdb

6)来创建一些测试文档:

curl -X放置"http://127.0.0.1:5984/testdb/1“-d "{\" Name \":\"My Name 1\"}” curl -X放置"http://127.0.0.1:5984/testdb/2“-d "{\" Name \":\"My Name 2\"}” curl -X放置"http://127.0.0.1:5984/testdb/3“-d "{\" Name \":\"My Name 3\"}” curl -X放置"http://127.0.0.1:5984/testdb/4“-d "{\" Name \":\"My Name 4\"}”

7)使用数据库设置ElasticSearch

-X将"127.0.0.1:9200/_river/testdb/_meta“{ \"type\”:\"couchdb\“、\"couchdb\”:{ \"host\“:\"localhost\”、\“-d \”:\“testdb\”、\"filter\“:null }、\"index\”:{ \"index\“:\"testdb\",\"type\“:\"testdb\",\"bulk_size\”:\"100\",\"bulk_timeout\“:\"10ms\”}“

8)来测试它的

卷曲"search?pretty=true

代码语言:javascript
复制
on testing we should get this




{
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 4,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "testdb",
      "_type" : "testdb",
      "_id" : "4",
      "_score" : 1.0, "_source" : {"_rev":"1-7e9376fc8bfa6b8c8788b0f408154584","_id":"4","name":"My Name 4"}
    }, {
      "_index" : "testdb",
      "_type" : "testdb",
      "_id" : "1",
      "_score" : 1.0, "_source" : {"_rev":"1-87386bd54c821354a93cf62add449d31","_id":"1","name":"My Name"}
    }, {
      "_index" : "testdb",
      "_type" : "testdb",
      "_id" : "2",
      "_score" : 1.0, "_source" : {"_rev":"1-194582c1e02d84ae36e59f568a459633","_id":"2","name":"My Name 2"}
    }, {
      "_index" : "testdb",
      "_type" : "testdb",
      "_id" : "3",
      "_score" : 1.0, "_source" : {"_rev":"1-62a53c50e7df02ec22973fc802fb9fc0","_id":"3","name":"My Name 3"}
    } ]
  }
}

但我得到了这样的东西

代码语言:javascript
复制
{
  "error" : "IndexMissingException[[testdb] missing]",
  "status" : 404
}
EN

回答 1

Stack Overflow用户

发布于 2015-03-19 23:51:29

这个卷曲字符串不需要额外的testb。这是:

代码语言:javascript
复制
curl "http://127.0.0.1:9200/testdb/testdb/_search?pretty=true"

应该是这样:

代码语言:javascript
复制
curl 'http://localhost/testdb/_search?pretty=true'

您可以通过运行以下命令来查看所有内容,并确保搜索是针对您的索引之一的:

curl -X GET 'localhost:9200/_cat/indices'

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28417224

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档