【问题标题】:In Apache Solr How to retrieve deleted documents在 Apache Solr 中如何检索已删除的文档
【发布时间】:2020-08-10 11:02:32
【问题描述】:

每当我使用 solr 索引文档时,我的核心已删除文档数也会增加。我想查看被删除的文档。

【问题讨论】:

  • 如果它们在您编制索引时被标记为已删除,则旧文档被替换为较新的文档 - 即文档的旧版本被删除并取而代之。除非您在索引过程中发出显式删除,否则很可能会发生这种情况。已删除的文档仍会出现在索引文件中,因此您也可以使用 Luke 稍作修改来查看这些文件:github.com/DmitryKey/luke/issues/105

标签: java indexing solr


【解决方案1】:

您可以在它们被删除之前附加一个监听器和日志条目。 您也可以将它们写入自定义文件中,该文件仅包含已删除条目的详细信息。

删除条目时,您也可以使用该代码示例实现自己的逻辑: https://www.tutorialspoint.com/apache_solr/apache_solr_deleting_documents.htm

import java.io.IOException;  

import org.apache.Solr.client.Solrj.SolrClient; 
import org.apache.Solr.client.Solrj.SolrServerException; 
import org.apache.Solr.client.Solrj.impl.HttpSolrClient; 
import org.apache.Solr.common.SolrInputDocument;  

public class DeletingAllDocuments { 
   public static void main(String args[]) throws SolrServerException, IOException {
      //Preparing the Solr client 
      String urlString = "http://localhost:8983/Solr/my_core"; 
      SolrClient Solr = new HttpSolrClient.Builder(urlString).build();   
      
      //Preparing the Solr document 
      SolrInputDocument doc = new SolrInputDocument();   
          
      //Deleting the documents from Solr 
      Solr.deleteByQuery("*");        
         
      //Saving the document 
      Solr.commit(); 
      System.out.println("Documents deleted"); 
   } 
}

【讨论】:

  • 您好,这将在以后文档被删除但我想找回已经删除的文档后帮助我。有什么办法吗?
  • 只需查看您的备份即可检索已删除的文档。希望你以前做过一些备份。如果它们被标记为“已删除”,那么您获得它们的可能性很小,因为您可以在索引中找到它们。但根本不能保证。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-05
  • 1970-01-01
  • 2016-06-14
相关资源
最近更新 更多