2012-03-02 45 views
2

我想將clojure-solr庫升級到1.3(我原本沒有寫它,這是一個fork),並且在與apache-solr-3.5.0進行交互時遇到問題。下面是在GitHub上更新庫:Clojure/Solr:嘗試從Clojure使用org.apache.solr.client.solrj.impl.CommonsHttpSolrServer時發生異常

https://github.com/antler/clojure-solr

這是基本上只是進口準系統Java類的非常簡單的一個文件的項目。我試圖連接到自帶的Solr 3.5.0版本捆綁Solr的示例應用程序(這是一個鏡像):

http://www.fightrice.com/mirrors/apache//lucene/solr/3.5.0/

在此版本中我cd到例如/和運行

java -jar start.jar 

這似乎工作正常。然後,從Clojure的-的Solr項目REPL(運行後雷音DEPS):

(use 'clojure-solr) 

(with-connection (connect "http://127.0.0.1:8983/solr") 
    (add-document! {"id" "testdoc", "name" "A Test Document"}) 
    (add-documents! [{"id" "testdoc.2", "name" "Another test"} 
        {"id" "testdoc.3", "name" "a final test"}]) 
    (commit!) 
    (search "test") 
    (search "test" :rows 2)) 

這是從原來的庫給出的例子。呼叫連接運行正常,但未能上添加具有以下異常:

IllegalArgumentException No matching field found: add 
    for class org.apache.solr.client.solrj.impl.CommonsHttpSolrServer 

我在Solr的文檔和add方法檢查肯定是存在的:

http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.html

我在想什麼這裏?謝謝你的幫助!

回答

3

clojure-solr將文檔向量轉換爲add-documents!中的數組。然而,對於數組沒有.add方法CommonsHttpSolrServer

更改clojure-solr傳遞矢量可能會解決這個問題,因爲矢量實現了java.util.List - 因此java.util.Collection。未經測試。只是一個猜測。

0

如何使用類似:

(add-documents! (list {"id" "testdoc.2", "name" "Another test"} 
        {"id" "testdoc.3", "name" "a final test"})) 

OR

(add-documents! '({"id" "testdoc.2", "name" "Another test"} 
        {"id" "testdoc.3", "name" "a final test"})) 
相關問題