Quantcast
Channel: How to update the existing field of solr index using java? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to update the existing field of solr index using java?

$
0
0

I have a Solr index in a core having 3000 documents.

I want to modify the value of a single field in the entire core based on unique key PaperID.

I'm using the following java code but instead of updating the existing value it adds new documents.

if (solrDocument.get("PaperID").equals(solrDocument2.get("PaperID"))) {    String Mscore = (String) solrDocument.get("ID");    String ModifyScore = (String) solrDocument.get("Author");    //solrDocument.setField("ID", ModifyScore);    //update the field    System.out.println(Mscore);    System.out.println(ModifyScore);    System.out.println(solrDocument2.get("Mscore") +"\n");    SolrInputDocument sid = new SolrInputDocument();    Map<String, Object> fieldModifier = new HashMap<String, Object>(1);    fieldModifier.put("set", ModifyScore);    sid.setField("ID", fieldModifier);    //solr.add(sid);    solr.commit();}

can anyone guide me accordingly...Best Regards


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images