Reputation: 9049
I am trying to upgrade the clojure-solr library to 1.3 (I did not write it originally, this is a fork) and I am encountering a problem when interacting to apache-solr-3.5.0. Here is the updated library on github:
https://github.com/antler/clojure-solr
It is a very simple one file project that basically just imports the barebones java classes. I am trying to connect to the solr example app that comes bundled with the solr 3.5.0 release (this is one mirror):
http://www.fightrice.com/mirrors/apache//lucene/solr/3.5.0/
In this release I cd into example/ and run
java -jar start.jar
This seems to work fine. Then, from the repl in the clojure-solr project (after running lein 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))
This is from the example given in the library originally. The call to connect runs fine, but fails on add with the following exception:
IllegalArgumentException No matching field found: add
for class org.apache.solr.client.solrj.impl.CommonsHttpSolrServer
I checked in the solr docs and the add method is definitely there:
http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.html
What am I missing here? Thanks for any help!
Upvotes: 2
Views: 392
Reputation: 2543
As of 2019 corona clojure solr wrapper is the way to go.
(corona.index/add! client-config [{"id" "testdoc.2", "name" "Another test"}
{"id" "testdoc.3", "name" "a final test"}])
Is doesn't rely on Solrj, but rather directly on REST API.
Example usage here: https://github.com/Stylitics/corona-demo
Upvotes: 0
Reputation: 335
How about using something like:
(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"}))
Upvotes: 0
Reputation: 17299
clojure-solr turns the vector of documents into an array in add-documents!
. However there is no .add
method of CommonsHttpSolrServer
for an array.
Changing clojure-solr to pass on a vector might fix the issue since a vector implements java.util.List
- and thusly java.util.Collection
. Not tested. Just a guess.
Upvotes: 3