简体   繁体   English

使用SolrJ删除整个索引

[英]Delete an entire index with SolrJ

I'm using SolrJ to index articles on my site. 我正在使用SolrJ在我的网站上为文章建立索引。 Periodically, I'm going to want to clear the whole index and do a fresh re-index of all articles. 我将定期要清除整个索引,并对所有文章进行新的重新索引。

The ID of each entry is tied to the ID of the article (something to the effect of [blog ID]-[article ID]). 每个条目的ID与文章的ID相关联(这与[博客ID]-[文章ID]的影响有关)。 I know that SolrJ has a deleteById() method, but if an article is removed from my site, I may lose access to its ID on the Java side, so I can't reliably iterate over all articles and call deleteById(). 我知道SolrJ有一个deleteById()方法,但是如果从我的网站上删除了一篇文章,我可能会失去在Java端对其ID的访问权限,因此我无法可靠地遍历所有文章并调用deleteById()。 Is there any way to drop an entire index using SolrJ? 有没有办法使用SolrJ删除整个索引?

Use 采用

server.deleteByQuery( "*:*" );

Then 然后

server.commit()

You should first delete by query, do a full index, and then commit, so that the old index remains until the new one is committed. 您应该首先通过查询删除,执行完整索引,然后提交,以便旧索引一直保留到新索引提交为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM