3

私はデータのグラフィカル表現に取り組んでいます。グラフは JSON データを受け入れるため、couchdb から必要なデータをフェッチする必要があります。私はelasticsearchサーバーを使用してcouchdbのインデックスを作成しているため、必要なデータを取得しています。私はelasticsearch Riverプラグインを使用してcouchdbとelasticsearchサーバーを一緒に作成しています。

CouchDB データベース 'testdb' を作成し、同じテスト ドキュメントをいくつか作成しました。データベースでelasticsearchをセットアップします。デフォルトの検索基準で CURl GET コマンドを記述して同じことをテストすると、「総ヒット数」が 0 を超えなければならず、「ヒット数」には検索基準に対する応答値が含まれている必要があります。しかし、「総ヒット数」は 0 であり、「ヒット数」:[] (つまり null)

私が従った手順。

1)couchdbの最新バージョンをダウンロードしてインストールしました

2) CouchDB が実行されていることを確認

カール ローカルホスト:5984

I got response that starts with:

{"couchdb":"Welcome"...

3) ElasticSearch のダウンロードとサービスのインストール

service.bat インストール

カールhttp://127.0.0.1:9200

I got response as


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

4) ElasticSearch 1.4.2 用の CouchDB River Plugin をインストールしました。

プラグイン -elasticsearch/elasticsearch-river-couchdb/2.4.1 をインストールします

5) CouchDB データベースと ElasticSearch インデックスを作成するには

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

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/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) データベースで 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\" } }"

8) テストする

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

しかし、私はこのようなものを手に入れました

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

1 に答える 1

0

このカール文字列には、追加のtestb. これ:

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

これでなければなりません:

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

以下を実行し、検索がインデックスの 1 つに対して行われていることを確認することで、すべてを表示できます。

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

于 2015-03-19T23:51:29.290 に答える