3
votes

I am working on graphical representation of data. The graph accepts JSON data,hence I need to fetch the required data from couchdb. I am using elasticsearch server for indexing couchdb and hence retrieve required data. I am using elasticsearch river plugin to make couchdb and elasticsearch server together.

I have Created the CouchDB Database 'testdb' and created some test documents for the same. Setup elasticsearch with the database. 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. But we are getting 'total hits' as 0 and 'hits':[] (i.e. null)

Procedures I followed.

1) Downloaded and installed couchdb latest version

2) Verified CouchDB is running

curl localhost:5984

I got response that starts with:

{"couchdb":"Welcome"...

3) Downloaded ElasticSearch and installed service

service.bat install

curl 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

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

5) To Create the CouchDB Database and ElasticSearch Index

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

6) To Create some test documents:

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/2" -d "{\"name\":\"My 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/4" -d "{\"name\":\"My Name 4\"}"

7) To Setup ElasticSearch with the Database

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

curl "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
}
1
Any errors in your logs that you could provide? You may want to try creating the index and the type before creating the river that points to it.tsturzl

1 Answers

0
votes

This curl string doesn't need the additional 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'