Solr 删除数据的几种方式
2016-06-07 16:12
351 查看
有时候需要删除 Solr 中的数据(特别是不重做索引的系统中,在重做索引期间)。删除一些 Solr 无效数据(或不合格数据)。
删除 solr 中的数据有几种方式:
1、先来看 curl 方式:
curl http://localhost:8080/solr/update --data-binary "<delete><query>title:abc</query></delete>" -H 'Content-type:text/xml; charset=utf-8'
#删除完后,要提交
curl http://localhost:8080/solr/update --data-binary "<commit/>" -H 'Content-type:text/xml; charset=utf-8'
2、用自带的 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
3、直接用 url,使用 stream 相关参数:
比如:
http://localhost:8080/solr/update/?stream.body=<delete><id>123</id></delete>&stream.contentType=text/xml;charset=utf-8&commit=true
stream 相关参数还有:stream.file=(服务器本地文件),stream.url 分别指到你的删除文本,这里是直接字符串内容用 stream.body 参数。commit 参数是指提交,提交了才能看到删除效果。
小结:其实,方式1、2原理一样,直接 POST xml 数据过去。方式3就是直接可以告诉服务器从那些地方取删除的 xml 内容。
删除指令有两种,一是:用 <id></id> 包装;二是:<query></query> 包装。指令都很明显,一个是 id 值(是在 schema.xml 的 uniqueKey 所指字段的值,而不是索引内部的 docId);query 值是查询串,如:title:"solr lucene"
Solr 删除全部索引:http://localhost:8080/solr/update/?stream.body=<delete><query>*:*</query></delete>&stream.contentType=text/xml;charset=utf-8&commit=true
solr 删除指定ID的索引:http://localhost:8080/solr/update/?stream.body=<delete><id>1</id></delete>&stream.contentType=text/xml;charset=utf-8&commit=true
原文出处:http://blog.chenlb.com/2010/03/solr-delete-data.html
删除 solr 中的数据有几种方式:
1、先来看 curl 方式:
curl http://localhost:8080/solr/update --data-binary "<delete><query>title:abc</query></delete>" -H 'Content-type:text/xml; charset=utf-8'
#删除完后,要提交
curl http://localhost:8080/solr/update --data-binary "<commit/>" -H 'Content-type:text/xml; charset=utf-8'
2、用自带的 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
3、直接用 url,使用 stream 相关参数:
比如:
http://localhost:8080/solr/update/?stream.body=<delete><id>123</id></delete>&stream.contentType=text/xml;charset=utf-8&commit=true
stream 相关参数还有:stream.file=(服务器本地文件),stream.url 分别指到你的删除文本,这里是直接字符串内容用 stream.body 参数。commit 参数是指提交,提交了才能看到删除效果。
小结:其实,方式1、2原理一样,直接 POST xml 数据过去。方式3就是直接可以告诉服务器从那些地方取删除的 xml 内容。
删除指令有两种,一是:用 <id></id> 包装;二是:<query></query> 包装。指令都很明显,一个是 id 值(是在 schema.xml 的 uniqueKey 所指字段的值,而不是索引内部的 docId);query 值是查询串,如:title:"solr lucene"
Solr 删除全部索引:http://localhost:8080/solr/update/?stream.body=<delete><query>*:*</query></delete>&stream.contentType=text/xml;charset=utf-8&commit=true
solr 删除指定ID的索引:http://localhost:8080/solr/update/?stream.body=<delete><id>1</id></delete>&stream.contentType=text/xml;charset=utf-8&commit=true
原文出处:http://blog.chenlb.com/2010/03/solr-delete-data.html
相关文章推荐
- jsp动作元素:<jsp:include>动作元素
- 去掉UISearchBar的那个灰色背景框,,
- 性能瓶颈调优
- 金士顿U盘,群联PS2251-60主控,量产CDROM教程
- 绝对定位元素水平居中
- sql存储过程——名称 ****不是有效的标识符
- 如何使用JSON格式 POST数据到服务器
- 创建 Web 前端开发环境(node和npm)
- AXI DMA(2)简单的DMA传输寄存器编程顺序(不是SG)
- webservice cxf与servlet集成
- JOptionPane.showInputDialog & JOptionPane.showConfirmDialog & showMessageDialog的应用
- 3033: 太鼓达人
- Anandkumar:高维学习概率隐性变量模型及张量算法的设计分析
- OS_threading
- CSS实现背景透明,文字不透明,兼容所有浏览器
- Redhat7/Centos7 命令不能补全解决方法
- SPFA输出路径
- mobileDetect.js
- [DNS][转]EDNS
- oracle union