因为我的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 删除指定ID的索引: http://localhost:8080/solr/update/?stream.body=<delete><id>1</id></delete>&stream.contentType=text/xml;charset=utf-8&commit=true1删除制定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>"