Indexing data using XPath

For simplicity, we'll use FileDataSource. With it, we can import data into Solr from XML files using XPathEntityProcessor to retrieve the data.

Let's go ahead and create a new core named MusicCatalogue-DIH-XPath in Solr. We can create the configuration files similarly to the ones we previously created for JDBCDataSource.

In solrconfig.xml, we'll use the following content:

  <requestHandler name="/dataimport" class="solr.DataImportHandler">
    <lst name="defaults">
      <str name="config">xpath-data-config.xml</str>
    </lst>
  </requestHandler>

We'll create a new file called xpath-data-config.xml, which will contain FileDataSource and XPathEntityProcessor:

<dataConfig> <!-- File Data Source --> <dataSource type="FileDataSource" encoding="UTF-8" ...

Get Apache Solr for Indexing Data now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.