2011-10-14 51 views
2

我創建了一個CouchDB的河流(從這個elasticsearch example)爲elasticsearch用下面的代碼:搜索CouchDB的使用ElasticSearch河

curl -XPUT 'localhost:9200/_river/tasks/_meta' -d '{ 
"type" : "couchdb", 
"couchdb" : { 
    "host" : "localhost", 
    "port" : 5984, 
    "db" : "tasks", 
    "filter" : null 
}, 
"index" : { 
    "index" : "tasks", 
    "type" : "tasks", 
    "bulk_size" : "100", 
    "bulk_timeout" : "10ms" 
} 
}' 

當我嘗試使用elasticsearch用這個命令來搜索CouchDB的:

curl -XGET http://localhost:9200/tasks/tasks -d query{"user":"jbattle"} 

我得到的迴應: 沒有處理髮現的URI [/任務/任務]和方法[GET] []

我是在尋找但尚未發現解決方案/爲這個問題。

UPDATE:

我已經發現了正確的查詢是:

curl -XGET 'http://localhost:9200/_river/tasks/_search?q=user:jbattle&pretty=true' 

雖然,儘管不再收到一個錯誤,我得到0命中:

{ 
    "took" : 1, 
    "timed_out" : false, 
    "_shards" : { 
    "total" : 1, 
    "successful" : 1, 
    "failed" : 0 
    }, 
    "hits" : { 
    "total" : 0, 
    "max_score" : null, 
    "hits" : [ ] 
} 

回答

1

兩個您的查詢不正確。第一個是缺少端點/_search,第二個是查詢索引_river而不是索引tasks

_river索引是存儲您的河流而不是您的數據。當您配置您的河流時,您指定了索引tasks

那麼試試這個來代替:

curl -XGET 'http://localhost:9200/tasks/tasks/_search?q=user:jbattle&pretty=true' 

或者,如果還是不行,請嘗試tasks/tasks搜索任何文檔:

curl -XGET 'http://localhost:9200/tasks/tasks/_search?q=*&pretty=true' 

克林特

+0

謝謝。你的答案是現貨。現在,我需要處理如何索引字段。 再次感謝! – jbattle

0

The example file你貼得到移到github上。這些人讓a decent walkthrough沙發和elasticsearch一起工作。

不幸的是,目前接受的答案不適用於我。但是如果我在瀏覽器的地址欄中粘貼這樣的東西,它就會起作用。請注意,URL中只有一個對「任務」索引的引用,而不是兩個。

http://localhost:9200/tasks/_search?pretty=true 

要做一個真正的搜索,你可以嘗試這樣的:

http://localhost:9200/tasks/_search?q="hello"&pretty=true