chutsu
chutsu

Reputation: 14103

How do you insert a JSON document to Solr using Solrj

There are examples of inserting or "updating" JSON documents to Solr, however I was wondering how do I achieve the same thing using Solrj (Solr Java Client)?

Or should I just open a socket and send it through that?

Note: I'm using Solr 4.0

Upvotes: 2

Views: 4192

Answers (1)

javanna
javanna

Reputation: 60235

With SolrJ you can either add POJOs to Solr using the @Field annotation or SolrInputDocument instances, which are more less maps containing the document fields. You cannot directly add a Json document. If you have a Json document already available you can transform it back to a Java object using Jackson, annotate it and send it through SolrJ or send the request via httpclient without using SolrJ at all.

Upvotes: 3

Related Questions