SOLR: Curl update all files

518 views Asked by At

Is there anyway to use the curl command to update the solr with all the files under a directory? For example like update all the XML files:

curl "http://localhost:8983/solr/xml/update?commit=true&tr=add.xsl" -H "Content-Type: text/xml" --data-binary @*.xml

Using the post.jar, I was able to run these updates, but I am not looking the same function on using CURL ?

Thanks in advance.

1

There are 1 answers

2
MatsLindh On

I don't think CURL supports making wildcard posts through --data-binary. It does support some globbing in its -T parameter, but that issues a PUT (as it uses the baseurl + filename). You'll also have to expand the list yourself, as I couldn't get * to work as globbing pattern.

The easiest way is probably to wrap it in a for-loop instead, which will depend on how you're running curl (and what OS or shell you're using).

#!/usr/bin/env bash
for FILE in *.xml
do
    curl "http://localhost:8983/solr/xml/update?commit=true&tr=add.xsl" -H "Content-Type: text/xml" --data-binary @$FILE
done