O'Reilly logo

Apache Solr for Indexing Data by Anshul Johri, Sachin Handiekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required