SOLRJ API to do similar CURL command execution

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SOLRJ API to do similar CURL command execution

Anupam Bhattacharya
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
Reply | Threaded
Open this post in threaded view
|

Re: SOLRJ API to do similar CURL command execution

Anupam Bhattacharya
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 <[hidden email]>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
Reply | Threaded
Open this post in threaded view
|

Re: SOLRJ API to do similar CURL command execution

Koji Sekiguchi
(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