简体   繁体   English

如何在elasticsearch河流插件的帮助下从elasticsearch服务器索引couchdb,从而获得JSON数据

[英]How to index couchdb from elasticsearch server with the help of elasticsearch river plugin and hence get JSON data

I am working on graphical representation of data. 我正在研究数据的图形表示。 The graph accepts JSON data,hence I need to fetch the required data from couchdb. 该图接受JSON数据,因此我需要从couchdb获取所需的数据。 I am using elasticsearch server for indexing couchdb and hence retrieve required data. 我使用elasticsearch服务器索引couchdb,因此检索所需的数据。 I am using elasticsearch river plugin to make couchdb and elasticsearch server together. 我正在使用elasticsearch河流插件将couchdb和elasticsearch服务器组合在一起。

I have Created the CouchDB Database 'testdb' and created some test documents for the same. 我创建了CouchDB数据库'testdb'并为其创建了一些测试文档。 Setup elasticsearch with the database. 使用数据库设置elasticsearch。 On testing the same by writing CURl GET command with default search criteria, we must get 'total hits' more than 0 and the 'hits' must have some response value for searched criteria. 在通过使用默认搜索条件编写CURl GET命令来测试相同内容时,我们必须使“总命中数”大于0,并且“命中”必须对搜索条件具有一些响应值。 But we are getting 'total hits' as 0 and 'hits':[] (ie null) 但我们将“总命中率”设为0和'命中':[](即null)

Procedures I followed. 我遵循的程序。

1) Downloaded and installed couchdb latest version 1)下载并安装了couchdb最新版本

2) Verified CouchDB is running 2)已验证的CouchDB正在运行

curl localhost:5984 curl localhost:5984

I got response that starts with:

{"couchdb":"Welcome"...

3) Downloaded ElasticSearch and installed service 3)下载ElasticSearch并安装了服务

service.bat install service.bat安装

curl http://127.0.0.1:9200 卷曲http://127.0.0.1:9200

I got response as


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

4) Installed the CouchDB River Plugin for ElasticSearch 1.4.2 4)为ElasticSearch 1.4.2安装了CouchDB River插件

plugin -install elasticsearch/elasticsearch-river-couchdb/2.4.1 plugin -install elasticsearch / elasticsearch-river-couchdb / 2.4.1

5) To Create the CouchDB Database and ElasticSearch Index 5)创建CouchDB数据库和ElasticSearch索引

curl -X PUT " http://127.0.0.1:5984/testdb " curl -X PUT“ http://127.0.0.1:5984/testdb

6) To Create some test documents: 6)创建一些测试文档:

curl -X PUT " http://127.0.0.1:5984/testdb/1 " -d "{\\"name\\":\\"My Name 1\\"}" curl -X PUT“ http://127.0.0.1:5984/testdb/1 ”-d“{\\”name \\“:\\”我的名字1 \\“}”
curl -X PUT " http://127.0.0.1:5984/testdb/2 " -d "{\\"name\\":\\"My Name 2\\"}" curl -X PUT“ http://127.0.0.1:5984/testdb/2 ”-d“{\\”name \\“:\\”我的名字2 \\“}”
curl -X PUT " http://127.0.0.1:5984/testdb/3 " -d "{\\"name\\":\\"My Name 3\\"}" curl -X PUT“ http://127.0.0.1:5984/testdb/3 ”-d“{\\”name \\“:\\”我的名字3 \\“}”
curl -X PUT " http://127.0.0.1:5984/testdb/4 " -d "{\\"name\\":\\"My Name 4\\"}" curl -X PUT“ http://127.0.0.1:5984/testdb/4 ”-d“{\\”name \\“:\\”我的名字4 \\“}”

7) To Setup ElasticSearch with the Database 7)使用数据库设置ElasticSearch

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

8) To test it 8)测试它

curl " http://127.0.0.1:9200/testdb/testdb/_search?pretty=true " 卷曲“ http://127.0.0.1:9200/testdb/testdb/_search?pretty=true

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"}
    } ]
  }
}

But I got something like this 但我有这样的事情

{
  "error" : "IndexMissingException[[testdb] missing]",
  "status" : 404
}

This curl string doesn't need the additional testb . 此卷曲字符串不需要额外的testb This: 这个:

curl "http://127.0.0.1:9200/testdb/testdb/_search?pretty=true"

Should be this: 应该是这样的:

curl 'http://localhost/testdb/_search?pretty=true'

You can view all your by running the following and ensuring your search is against one of your indices: 您可以通过运行以下命令查看所有内容,并确保您的搜索针对您的某个索引:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM