Indexing updates using CSV

At last, we'll now see how we can index CSV data in Solr using Content-Type: text/csv. A sample CSV file has been provided at %SOLR_EXAMPLES/Chapter-4/sampleMusicCatalog.csv, and we can use it to add documents to our musicCatalgoue example.

The following is an example of indexing data using the curl command:

curl 'http://localhost:8983/solr/musicCatalog/update' --data-binary @sampleMusicCatalog.csv -H 'Content-type:application/csv'

In the preceding command, we're telling CSVUpdateHandler to use the first line of the CSV as the header row, which will contain the field name. If the CSV does not have a header row, we can use the header=false parameter, which will tell UpdateHandler that there is no header row present. We ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.