好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

solr提交索引删除索引方式概述

添加索引的时候,xml数据文件需要包含utf-8声明,

然后使用Solr自带的post.jar或者curl来进行post索引:

java方式:

java - Durl = http : //localhost:8080/solr/update -Dcommit=yes -jar post.jar data.xml

curl方式

代码如下

curl - F "file=@data.xml" http : //localhost:8080/solr/update

curl - H "Content-Type: text/xml" - d "" http : //localhost:8080/solr/update

 该步骤如果没有设置好,出错的表现是,查询的结果是乱码(可以设置查询关键词为id:[* TO *]确保显示出所有的结果).  

1删除制定ID的索引

java -Ddata=args -Durl=http://localhost:8081/apache-solr-test/core0/update -jar  post.jar "<delete><id>05138022</id></delete>"

2.删除查询到的索引数据

java -Ddata=args -Durl=http://localhost:8081/apache-solr-test/core0/update -jar  post.jar "<delete><query>id:IW-02</query></delete>"

3.删除所有索引数据

java -Ddata=args -Durl=http://localhost:8081/apache-solr-test/core0/update -jar  post.jar "<delete><query>*:*</query></delete>"

 

查询参数

q - 查询字符串,必须的。

fl - 指定返回那些字段内容,用逗号或空格分隔多个。

start - 返回第一条记录在完整找到结果中的偏移位置,0开始,一般分页用。

rows - 指定返回结果最多有多少条记录,配合start来实现分页。

sort - 排序,格式:sort=<field name>+<desc|asc>[,<field name>+<desc|asc>]… 。示例:(inStock desc, price asc)表示先 [inStock] 降序, 再 [price] 升序,默认是相关性降序。

wt - (writer type)指定输出格式,可以有 xml, json, php, phps, 后面 solr 1.3增加的,要用通知我们,因为默认没有打开。

fq - (filter query)过虑查询,作用:在q查询符合结果中同时是fq查询符合的,例如:q=mm&fq=date_time:[20081001 TO 20091031],找关键字mm,并且date_time是20081001到20091031之间的。官方文档:http://wiki.apache.org/solr/CommonQueryParameters#head-6522ef80f22d0e50d2f12ec487758577506d6002

q.op - 覆盖schema.xml的defaultOperator(有空格时用"AND"还是用"OR"操作逻辑),一般默认指定

df - 默认的查询字段,一般默认指定

qt - (query type)指定那个类型来处理查询请求,一般不用指定,默认是standard。

 

查看更多关于solr提交索引删除索引方式概述的详细内容...

  阅读:57次