Solr 直接删除文件达到清空索引目的

本文详细介绍了如何手动清除Solr索引,包括通过配置文件查找索引位置、删除索引文件及使用HTTP或curl命令进行索引操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

因为我的solr是程序里带的包,并非官网的包,有些方法并不适用,因此简单暴力的还就是直接删除索引文件:

1、在配置文件里找到索引文件所在位置:
solrconfig.xml
  <!-- Used to specify an alternate directory to hold all index data
       other than the default ./data under the Solr home.
       If replication is in use, this should match the replication configuration. -->
  <dataDir>./data</dataDir>

2、所以找到start.jar文件,的同级data目录,将目录下的index文件删除就行了,再次启动solr时会再自动创建。



网上已经有很多http或curl的办法:

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

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>"


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值