您的位置:首页 > 其它

solr删除数据的4种方便快捷的方式

2017-12-26 11:38 281 查看


solr删除数据的4种方便快捷的方式

1、在solr客户端,访问你的索引库(我认为最方便的方法)

1)documents type 选择 XML 

2)documents 输入下面语句

<delete><query>*:*</query></delete>

<commit/>

3)、



点击Submit Document 即可

2、solr-用url,使用 stream 相关参数删除数据:

如:

根据id删除数据

http://localhost:8080/solr/update/?stream.body=

<delete><id>id值</id></delete>&stream.contentType=text/xml;charset=utf-8&commit=true

根据查询参数条件删除数据

http://localhost:8080/solr/update/?stream.body=

<delete><query>参数</query></delete>&stream.contentType=text/xml;charset=utf-8&commit=true

stream 相关参数:

stream.file=(服务器本地文件);

stream.url 分别指到你的删除文本,这里是直接字符串内容用 stream.body 参数。

commit 参数是指提交,提交了才能看到删除效果。

删除指令有两种,一是:用 <id></id> 包装;二是:<query></query> 包装。指令都很明显,一个是 id 值(是在 schema.xml 的 uniqueKey 所指字段的值,而不是索引内部的 docId);query 值是查询串,如:title:"solr lucene"。

3、curl 方式:

curl  http://localhost:8080/update --data-binary  "<delete><query>title:abc</query></delete>"  -H 'Content- type :text/xml; charset=utf-8'  

  

#删除完后,要提交   

  

curl  http://localhost:8080/update --data-binary  "<commit/>"  -H 'Content- type:text/xml; charset=utf-8'  

4、用自带的 post.jar,在 apache-solr-XXX/example/exampledocs 目录下:

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

  

#怎么使用 post.jar 查看帮助   

  

java -jar post.jar -help 

小结:

方式1就是直接可以告诉服务器从那些地方去删除的数据内容;

方式2、3原理一样,直接 POST xml 数据过去;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: