How can I upload a file to Solr in Windows?
With solr 5.0 you have to mention core name while updating the docs. So the command to post all the examples in the exampledocs will be:
java -Dc="core_name" -jar post.jar *.xml
here replace core_name with the name of the core
If you want to use cURL command for posting files to solr, you are required to download this utility from cURL Home. Provide the path of cURL.exe in path environmental variable of the windows and then you can use the command you queried for
curl "http://localhost:8983/solr/update/extract?&extractOnly=true" --data-binary @"location of file/test.pdf" -H 'Content-type:application/pdf'
i.e. you are required to change the content type.
Another way to post the directory to Solr is by using the 'post.jar' utility in the examples directory of the Solr - remember this utility is not for production use.
Here is the sample command.
java -Ddata=files -Dtype=html -Dfiletypes=htm,html -Dauto=yes -Drecursive=yes -jar post.jar "Drive_letter:\yourpath\."
The above works perfectly with Solr 4.0
With the examples comes a post.jar
(see folder example\exampledocs
of the apache-solr-X.X.X.zip
):
java -jar post.jar -h
This is a simple command line tool for POSTing raw data to a Solr
port. Data can be read from files specified as commandline args,
as raw commandline arg strings, or via STDIN.
Examples:
java -jar post.jar *.xml
java -Ddata=args -jar post.jar '<delete><id>42</id></delete>'
java -Ddata=stdin -jar post.jar < hd.xml
java -Durl=http://localhost:8983/solr/update/csv -Dtype=text/csv -jar post.jar *.csv
java -Durl=http://localhost:8983/solr/update/json -Dtype=application/json -jar post.jar *.json
java -Durl=http://localhost:8983/solr/update/extract?literal.id=a -Dtype=application/pdf -jar post.jar a.pdf
Other options controlled by System Properties include the Solr
URL to POST to, the Content-Type of the data, whether a commit
or optimize should be executed, and whether the response should
be written to STDOUT. These are the defaults for all System Properties:
-Ddata=files
-Dtype=application/xml
-Durl=http://localhost:8983/solr/update
-Dcommit=yes
-Doptimize=no
-Dout=no
OR
The Windows PowerShell 3.0 has an Invoke-WebRequest
command which for sure could be used for that. See this blog post.