2015-02-09 51 views
3

我正在研究數據的圖形表示。該圖接受JSON數據,因此我需要從couchdb中獲取所需的數據。我正在使用elasticsearch服務器索引couchdb,因此檢索所需的數據。 我正在使用elasticsearch river插件將couchdb和elasticsearch服務器放在一起。如何在elasticsearch river插件的幫助下從elasticsearch服務器索引couchdb,從而得到JSON數據

我已經創建了CouchDB數據庫'testdb'併爲此創建了一些測試文檔。 設置elasticsearch與數據庫。 在使用默認搜索條件編寫CURl GET命令時,我們必須將「總點擊數」設置爲大於0,並且「點擊數」必須對搜索條件有一些響應值。 但我們將'總點擊數'設爲0和'命中':[](即空)

我遵循的程序。

CouchDB的驗證1)下載並安裝CouchDB的最新版本

2)運行

捲曲本地主機: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)安裝CouchDB的河插件ElasticSearch 1.4.2

plugin -install elasticsearch/elasticsearch-river-couchdb/2.4。1

5)來創建的CouchDB數據庫和索引ElasticSearch

捲曲-X PUT 「http://127.0.0.1:5984/testdb

6)來創建一些測試文件:

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 \」} 「
捲曲-X PUT 」 http://127.0.0.1:5984/testdb/3 「-d 」{\「 名稱\」:\ 「我的名字3 \」} 「
捲曲 -X PUT 」http://127.0.0.1:5984/testdb/4「 -d 」{\「 名稱\」: \ 「我的名字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 \」 \ 「類型\」:\ 「TESTDB \」,\ 「bulk_size \」: \ 「100 \」 \ 「bulk_timeout \」:\ 「10ms的\」}}」

8)爲了測試它

捲曲 「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 
} 
+0

任何錯誤在你可以提供的日誌中?您可能想在創建指向它的河流之前嘗試創建索引和類型。 – tsturzl 2015-02-10 00:08:50

回答

0

這捲曲字符串並不需要額外的testb。這:

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

應該是這樣的:

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

您可以查看所有通過運行以下命令,確保您的搜索是對你的指標之一:

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

相關問題