Solr XML Document Update

In this section of the tutorial, we will update the existing indexed documents with new records. In the previous section, we created the moneydata.xml XML document and added it to the Solr index. Now we will update the documents of id=USD with the below new records.

We have created a new XML file with the name moneydata_update.xml and we will use this file to update the existing index records.

The content of the moneydata_update.xml file is mentioned below.

<add> <doc> <field name="id">USD</field> <field name="name" update="set">Dollar Crrency</field> <field name="manu" update="add">United States of America Bank</field> <field name="cat" update="add">It is currency</field> <field name="features" update="add">Coins and notes</field> <field name="price_c" update="add">1,United States Dollar</field> <field name="inStock" update="add">present</field> </doc> </add>

solr xml file cloudduggu

We will use the moneydata_update.xml file to update the existing index records which were added as a moneydata.xml in the previous section.


cloudduggu@ubuntu:~/hadoop/solr-8.8.1/bin$ ./post -c Solr_sample_core moneydata_update.xml


After the successful execution of the command, we will see the following output.

solr update command example cloudduggu

We can verify the record update in the Solr web portal as well. Click on the Query tab and Execute the query by clicking on the Execute Query button. We can see the updated records in the output.

solr update verification cloudduggu