You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Anupam Bhattacharya <an...@gmail.com> on 2013/11/13 14:20:40 UTC

SOLRJ API to do similar CURL command execution

I am able to perform the xml atomic update properly using curl commands.
However the moment I try to achieve the same using the solrj APIs I am
facing problems.

What should be the equivalent SOLRJ api code to perform similar action
using the below CURL command ?

curl "http://search1.es.dupont.com:8080/solr/core1/update" -H
"Content-Type: text/xml" --data-binary "<add><doc><field
name=\"id\">uniqueid</field><field name=\"tags\"
update=\"add\">updatefieldvalue</field></doc></add>"

I have attempted below code but it fails to add the field in proper manner
as it get set as {add=[updatefieldvalue]}.

QueryResponse qs2 = solr.query(params2);
Map<String, List<String>> operation = new HashMap<String, List<String>>();
List<String> vals = new ArrayList<String>();
vals.add(tag);
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", (String)qs2.getResults().get(j).get("id"));
operation.put("add",vals);
doc.addField("tags", operation);

Thanks in advance for any inputs.

Regards
Anupam

Re: SOLRJ API to do similar CURL command execution

Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
(13/11/13 22:25), Anupam Bhattacharya wrote:
> How can I post the whole XML string to SOLR using its SOLRJ API ?
>
>

The source code of SimplePostTool would be of some help:

http://lucene.apache.org/solr/4_5_1/solr-core/org/apache/solr/util/SimplePostTool.html

koji
-- 
http://soleami.com/blog/automatically-acquiring-synonym-knowledge-from-wikipedia.html

Re: SOLRJ API to do similar CURL command execution

Posted by Anupam Bhattacharya <an...@gmail.com>.
How can I post the whole XML string to SOLR using its SOLRJ API ?


On Wed, Nov 13, 2013 at 6:50 PM, Anupam Bhattacharya <an...@gmail.com>wrote:

> I am able to perform the xml atomic update properly using curl commands.
> However the moment I try to achieve the same using the solrj APIs I am
> facing problems.
>
> What should be the equivalent SOLRJ api code to perform similar action
> using the below CURL command ?
>
> curl "http://search1.es.dupont.com:8080/solr/core1/update" -H
> "Content-Type: text/xml" --data-binary "<add><doc><field
> name=\"id\">uniqueid</field><field name=\"tags\"
> update=\"add\">updatefieldvalue</field></doc></add>"
>
> I have attempted below code but it fails to add the field in proper manner
> as it get set as {add=[updatefieldvalue]}.
>
> QueryResponse qs2 = solr.query(params2);
> Map<String, List<String>> operation = new HashMap<String, List<String>>();
> List<String> vals = new ArrayList<String>();
> vals.add(tag);
> SolrInputDocument doc = new SolrInputDocument();
> doc.addField("id", (String)qs2.getResults().get(j).get("id"));
> operation.put("add",vals);
> doc.addField("tags", operation);
>
> Thanks in advance for any inputs.
>
> Regards
> Anupam
>



-- 
Thanks & Regards
Anupam Bhattacharya