user13674325
user13674325

Reputation: 389

Update managed synonyms using SolrJ

I can update synonyms list using the REST call

curl -X POST -H 'Content-type:application/json' --data-binary '["angry","upset"]' "http://localhost:8983/solr/articles/schema/analysis/synonyms/english"

How to send same request using SolrJ?

Upvotes: 0

Views: 149

Answers (1)

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8678

Please try something like below.

SolrClient solrClient = new HttpSolrClient("http://localhost:8983/solr/my_collection");
ContentStreamBase.StringStream contentStream = new ContentStreamBase.StringStream(jsonBody);
contentStream.setContentType(JSON_CONTENT_TYPE);
ContentStreamUpdateRequest req = new ContentStreamUpdateRequest(updatePath);
req.addContentStream(contentStream);
return solrClient.request(req);

Note : Good Practice is send the solrClient object to the method.

Upvotes: 2

Related Questions