solr5.3.1 json xml csv 等文件类型,建立索引
2015-12-09 11:17
721 查看
在solr4.10中通过curl命令,可以对json文件建立索引,方式如下
可是换了solr5 尝试了很多次通过curl命令建立索引都失败了,没搞定为什么。
后来通过post.jar 提交本地文件的数据,例如json,xml等,支持很多种数据类型
post.jar 在下载的solr压缩包中的example-docs中,下面的命令需要在post.jar所在目录下执行。
加载一个json文件(需要将参数换成自己的solr core 和端口)
加载该目录下的所有该类型的文件(批量索引)
(xml,json,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log)
导入前需要将json等文件的属性全部添加到schema.xml的field中,否则会导入失败。
post.jar 可以接受很多参数。
curl http://localhost:8080/solr/update/json --data-binary @books.json -H 'Content-type:text/json; charset=utf-8'
可是换了solr5 尝试了很多次通过curl命令建立索引都失败了,没搞定为什么。
后来通过post.jar 提交本地文件的数据,例如json,xml等,支持很多种数据类型
post.jar 在下载的solr压缩包中的example-docs中,下面的命令需要在post.jar所在目录下执行。
加载一个json文件(需要将参数换成自己的solr core 和端口)
java -Dc=core0 -Dport=8080 -Dtype=application/json -jar post.jar books.json
加载该目录下的所有该类型的文件(批量索引)
java -Dc=core0 -Dport=8080 -Dtype=application/json -jar post.jar dir(目录)
(xml,json,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log)
导入前需要将json等文件的属性全部添加到schema.xml的field中,否则会导入失败。
post.jar 可以接受很多参数。
SimplePostTool version 5.1.0 Usage: java [SystemProperties] -jar post.jar [-h|-] [<file|folder|url|arg> [<file|folder|url|arg>...]] Supported System Properties and their defaults: -Dc=<core/collection> -Durl=<base Solr update URL> (overrides -Dc option if specified) -Ddata=files|web|args|stdin (default=files) -Dtype=<content-type> (default=application/xml) -Dhost=<host> (default: localhost) -Dport=<port> (default: 8983) -Dauto=yes|no (default=no) -Drecursive=yes|no|<depth> (default=0) -Ddelay=<seconds> (default=0 for files, 10 for web) -Dfiletypes=<type>[,<type>,...] (default=xml,json,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log) -Dparams="<key>=<value>[&<key>=<value>...]" (values must be URL-encoded) -Dcommit=yes|no (default=yes) -Doptimize=yes|no (default=no) -Dout=yes|no (default=no) This is a simple command line tool for POSTing raw data to a Solr port. NOTE: Specifying the url/core/collection name is mandatory. Data can be read from files specified as commandline args, URLs specified as args, as raw commandline arg strings or via STDIN. Examples: java -Dc=gettingstarted -jar post.jar *.xml java -Ddata=args -Dc=gettingstarted -jar post.jar '<delete><id>42</id></delete>' java -Ddata=stdin -Dc=gettingstarted -jar post.jar < hd.xml java -Ddata=web -Dc=gettingstarted -jar post.jar http://example.com/ java -Dtype=text/csv -Dc=gettingstarted -jar post.jar *.csv java -Dtype=application/json -Dc=gettingstarted -jar post.jar *.json java -Durl=http://localhost:8983/solr/techproducts/update/extract -Dparams=literal.id=pdf1 -jar post.jar solr-word.pdf java -Dauto -Dc=gettingstarted -jar post.jar * java -Dauto -Dc=gettingstarted -Drecursive -jar post.jar afolder java -Dauto -Dc=gettingstarted -Dfiletypes=ppt,html -jar post.jar afolder The 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. If auto=yes the tool will try to set type automatically from file name. When posting rich documents the file name will be propagated as "resource.name" and also used as "literal.id". You may override these or any other request parameter through the -Dparams property. To do a commit only, use "-" as argument. The web mode is a simple crawler following links within domain, default delay=10s.
相关文章推荐
- mysql load data 导出、导入 csv
- XML 与 JSON 优劣对比
- VBA将excel数据表生成JSON文件
- As3.0 xml + Loader应用代码
- 网马生成器 MS Internet Explorer XML Parsing Buffer Overflow Exploit (vista) 0day
- ext读取两种结构的xml的代码
- PostgreSQL教程(八):索引详解
- newtonsoft.json解析天气数据出错解决方法
- Oracle外键不加索引引起死锁示例
- oracle 索引的相关介绍(创建、简介、技巧、怎样查看) .
- C#针对xml基本操作及保存配置文件应用实例
- Ruby程序中创建和解析XML文件的方法
- asp下查询xml的实现代码
- 用SQL建立索引的方法步骤
- sqlserver FOR XML PATH 语句的应用
- 使用sp_xml_preparedocument处理XML文档的方法
- SQL效率提升之一些SQL编写建议并有效利用索引
- SQLSERVER的非聚集索引结构深度理解