Skip to content

Instantly share code, notes, and snippets.

@broquaint
Last active December 31, 2015 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save broquaint/8037288 to your computer and use it in GitHub Desktop.
Save broquaint/8037288 to your computer and use it in GitHub Desktop.
When I call addField on solr-doc in the let and evaluate solr-doc last I always end up with the exception.
galen.core> (let [solr-doc (SolrInputDocument.)]
(.getFieldValue solr-doc "id")
solr-doc)
{}
galen.core> (let [solr-doc (SolrInputDocument.)]
(.addField solr-doc "id" "xyz")
solr-doc)
ClassCastException org.apache.solr.common.SolrInputField cannot be cast to java.util.Map$Entry clojure.core/key (core.clj:1482)
galen.core> (let [solr-doc (SolrInputDocument.) _ (.addField solr-doc "id" "xyz")]
solr-doc)
ClassCastException org.apache.solr.common.SolrInputField cannot be cast to java.util.Map$Entry clojure.core/key (core.clj:1482)
galen.core> (let [solr-doc (SolrInputDocument.)]
(.addField solr-doc "id" "foo"))
nil
@broquaint
Copy link
Author

I believe this is happening because SolrInputField isn't behaving like a mappy-thing and so the REPL is failing to stringify it sensibly. The code itself operates just fine.

@solicode
Copy link

Thanks for this. I ran into the same problem today, and your post helped me out. Your conclusion seems correct.

I added a print-method that just calls toString on SolrInputDocument, and that fixed the problem I was having. Now I can run my code in the REPL without the ClassCastException creeping up.

(defmethod print-method SolrInputDocument [v w]
  (.write w (.toString v)))

I just thought I'd comment in case anybody else experiences this.

@erasmas
Copy link

erasmas commented Aug 21, 2015

Thanks for the comments, I encountered the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment