在 Apache Solr 中如何找回删除的文件
In Apache Solr How to retrieve deleted documents
每当我使用 solr 索引文档时,我的核心删除文档计数也会增加。我想查看正在删除的文档。
您可以在删除之前附加监听器和日志条目。
您也可以将它们写入仅包含已删除条目详细信息的自定义文件中。
删除条目时,您也可以使用该代码示例实现自己的逻辑:
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");
}
}
每当我使用 solr 索引文档时,我的核心删除文档计数也会增加。我想查看正在删除的文档。
您可以在删除之前附加监听器和日志条目。 您也可以将它们写入仅包含已删除条目详细信息的自定义文件中。
删除条目时,您也可以使用该代码示例实现自己的逻辑: 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");
}
}