0

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.

J-S
  • 85
  • 1
  • 10

1 Answers1

0

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
MatsLindh
  • 49,529
  • 4
  • 53
  • 84
  • Thanks @matslindh for your response. I was doing thru a loop, but I wanted to check as the post method using post.jar has the ability to do the wildcards method. – J-S Feb 11 '16 at 14:56
  • @J-S The post.jar iterates over each file it receives from the shell as far as I know. – MatsLindh Feb 11 '16 at 18:35