通過例子來一個post.jar
(見apache-solr-X.X.X.zip
的文件夾example\exampledocs
):
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
在Windows PowerShell 3.0具有Invoke-WebRequest
命令,它肯定可以使用爲了那個原因。見this blog post。
![Invoke-WebRequest](https://i.stack.imgur.com/EhYUn.png)
我試圖用post.jar張貼的PDF,但我得到一個錯誤。 SimplePostTool:致命:Solr返回錯誤#405方法不允許。 – John81
@John:你可以發表你正在使用的命令嗎? – jeha
@John:我剛剛嘗試過使用標準示例:通過'apache-solr-3.4.0 \ example> java -jar start.jar'啓動服務器,並將該文件發佈爲'apache-solr-3.4.0 \ example \ exampledocs> java -Durl = http:// localhost:8983/solr/update/extract?literal.id = foobar -Dtype = application/pdf -jar post.jar foobar.pdf'適合我... – jeha