liangxinye的gravatar头像
liangxinye 2016-01-09 14:28:23
apache solr中SimplePostTool工具

solr启动并运行之后,并不包含任何数据,在solr的安装目录下的bin目录中,有一个post工具,我们可以使用这个工具往solr上传数据,这个工具必须在命令行中执行,post工具是一个Unix脚本工具,没有windows版本(但可以在java程序中调用),我们可以使用SimplePostTool来代替,详情请参考:

https://cwiki.apache.org/confluence/display/solr/Post+Tool#PostTool-SimplePostTool

SimplePostTool工具是一个jar包,在%SOLR_HOME%\example\exampledocs目录下

这个工具可以直接运行在支持的环境中(包括Windows),使用如下命令运行:

java -jar example/exampledocs/post.jar

我们可以查看帮助以获得该工具的更多信息,如:上传文件(本地或网络文件夹)到Solr服务器、直接向Solr发送命令等,如下图:

java -jar example/exampledocs/post.jar –h

java [SystemProperties] -jar post.jar [-h|-] [<file|folder|url|arg> [<file|folder|url|arg>...]]

系统配置:

-Dc=core/collection

 

-Durl=solr的Url地址(如:http://127.0.0.1:8983/solr),该参数会覆盖-Dc参数,以上两个参数必须指定其中的一个,因为必须指定url/core/collection参数

 

-Ddata=files|web|args|stdin (default=files),该参数指定上传到Solr服务器的数据,默认为files (即文件):

files:本地资源,在命令行参数中指定文件或文件夹(<file|folder|url|arg>);

web:网络资源,在命令行参数中指定的URL地址(<file|folder|url|arg>);

args:命令行参数指定的字符串(<file|folder|url|arg>);

stdin:标准输入,在命令行中通过”<”符号指定输入流(如文件输入流);

Examples

java -Dc=gettingstarted -jar post.jar *.xml

java -Dtype=text/csv -Dc=gettingstarted -jar post.jar docs/

java -Ddata=web -Dc=gettingstarted -jar post.jar http://example.com/

java -Ddata=stdin -Dc=gettingstarted -jar post.jar < test.xml

java -Ddata=args -Dc=gettingstarted -jar post.jar "<id>42</id>"

java -Durl=http://localhost:8983/solr/gettingstarted/update/extract -Dparams=literal.id=pdf1 -jar post.jar solr-word.pdf


打赏
最近浏览
jinghao 2017年12月28日
暂无贡献等级
leo_zch  LV1 2017年10月20日
MrTrump 2017年9月19日
暂无贡献等级
yishunyongheng  LV1 2017年3月6日
364502984  LV18 2016年3月24日
xkrs1335180261  LV8 2016年1月19日
feihong247  LV8 2016年1月18日
1574359445  LV8 2016年1月18日
sadma0001  LV3 2016年1月18日
serical  LV12 2016年1月17日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友