Search code examples
curlsolr

upload csv to solr core using cURL on Windows


I've been looking around the web for good documentation for using solr on Windows, but I just can't find much out there. I'm using solr v5.4.1.

Following the tutorials here and here, I've installed solr and built a new core, installed cURL, and run what seems to be a curl command with no errors, but the data is not uploading to my server. I have modified schema.xml to include all of the column-header names that are in my CSV.

Here's the command I'm running to upload the data in test.csv to my core.

D:\solr\solr-5.4.1\bin>curl http://localhost:8983/solr/ti/update?commit=true --data-binary @d:\test.csv -H 'Content-type:application/csv'

and the response I get upon hitting enter:

<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int name="QTime">1071</int></lst>
</response>

When I go back to the Solr Admin panel, I see that 0 documents exist in my core, but I'm not getting any error message from curl, or from the response indicating I'm doing something wrong.

What am I doing wrong?


Solution

  • I couldn't figure it out in cURL, but I did figure out how to use the post.jar file that is bundled with solr to do it.

    #post a csv to a core named "abc" using the post.jar file in example\exampledocs

    I am running this command from D:\solr\solr-5.4.1\ where my solr installation lies.

    java -Dc=abc -Dtype=text/csv -Dfiletypes=text/csv -jar example\exampledocs\post.jar d:\test\test.csv
    

    Where:

    -Dc= is the name of the core that already exists in solr

    =Dtype= and Dfiletypes= is the type of file you're uploading

    -jar example\exampledocs\post.jar needs to be a reference to the location where your post.jar file exists.`

    D:\test\test.csv is the location of the csv file you're uploading.

    Also note, prior to this working, you need to modify the schema.xml file in solr to add the column headers in your CSV file to the solr core.

    Hope this helps SOMEONE! :)