Solr XML Document Addition
In this tutorial, we will go through the XML data addition in Apache Solr. In the previous section, we already covered the JSON and CSV format. The XML file format has the three important tags which are added, docs, and the fields. The add is the root tag that contains one or more docs tags to store one or many documents, the docs tags contain one or more field tags, and the last one is field tags which contains the actual data.
Let us see the below example to add a sample XML file of moneydata.xml file to Apache Solr index.
The moneydata.xml file contains the following records and we have created it in the /bin directory of Apache Solr home. The location of the file in our case is cloudduggu@ubuntu:~/hadoop/solr-8.8.1/bin$.
USD One Dollar Bank of America boa currency Coins and notes 1,USD true EUR One Euro European Union eu currency Coins and notes 1,EUR true GBP One British Pound U.K. uk currency Coins and notes 1,GBP true NOK One Krone Bank of Norway nor currency Coins and notes 1,NOK true
Now let us add the XML file moneydata.xml in the core Solr_sample_core using the Solr Post command as mentioned below.
Command:cloudduggu@ubuntu:~/hadoop/solr-8.8.1/bin$ ./post -c Solr_sample_core moneydata.xml
After successful execution of the command, we will see the below output.
We can verify the document addition from the Apache Solr web interface as well. Just click on the Query tab and increase the page to 30 and click on the Execute Query button.
We can see here the document has been added to the Solr index.