mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge branch 'feature/SEARCH-2027_TrackingDeleteDocs' into 'master'
Delete nodes only if they exist See merge request search_discovery/insightengine!294
This commit is contained in:
+29
-9
@@ -134,6 +134,7 @@ import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.LongPoint;
|
||||
import org.apache.lucene.index.IndexCommit;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
@@ -164,6 +165,9 @@ import org.apache.solr.schema.SchemaField;
|
||||
import org.apache.solr.search.DelegatingCollector;
|
||||
import org.apache.solr.search.DocIterator;
|
||||
import org.apache.solr.search.DocList;
|
||||
import org.apache.solr.search.DocSet;
|
||||
import org.apache.solr.search.QueryCommand;
|
||||
import org.apache.solr.search.QueryResult;
|
||||
import org.apache.solr.search.QueryWrapperFilter;
|
||||
import org.apache.solr.search.SolrIndexSearcher;
|
||||
import org.apache.solr.update.AddUpdateCommand;
|
||||
@@ -2190,16 +2194,24 @@ public class SolrInformationServer implements InformationServer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void deleteErrorNode(UpdateRequestProcessor processor, SolrQueryRequest request, Node node) throws IOException
|
||||
{
|
||||
|
||||
String errorDocId = PREFIX_ERROR + node.getId();
|
||||
DeleteUpdateCommand delErrorDocCmd = new DeleteUpdateCommand(request);
|
||||
delErrorDocCmd.setId(errorDocId);
|
||||
processor.processDelete(delErrorDocCmd);
|
||||
|
||||
// Try finding the node before performing removal operation
|
||||
DocSet docSet = request.getSearcher().getDocSet(new TermQuery(new Term(FIELD_SOLR4_ID, errorDocId)));
|
||||
|
||||
if (docSet.size() > 0)
|
||||
{
|
||||
DeleteUpdateCommand delErrorDocCmd = new DeleteUpdateCommand(request);
|
||||
delErrorDocCmd.setId(errorDocId);
|
||||
processor.processDelete(delErrorDocCmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void deleteNode(UpdateRequestProcessor processor, SolrQueryRequest request, Node node) throws IOException
|
||||
{
|
||||
LOGGER.debug("Deleting node {}", node.getId());
|
||||
@@ -2208,12 +2220,20 @@ public class SolrInformationServer implements InformationServer
|
||||
// MNT-13767 fix, remove by node DBID.
|
||||
deleteNode(processor, request, node.getId());
|
||||
}
|
||||
|
||||
|
||||
private void deleteNode(UpdateRequestProcessor processor, SolrQueryRequest request, long dbid) throws IOException
|
||||
{
|
||||
DeleteUpdateCommand delDocCmd = new DeleteUpdateCommand(request);
|
||||
delDocCmd.setQuery(FIELD_DBID + ":" + dbid);
|
||||
processor.processDelete(delDocCmd);
|
||||
|
||||
// Try finding the node before performing removal operation
|
||||
DocSet docSet = request.getSearcher().getDocSet(LongPoint.newExactQuery(FIELD_DBID, dbid));
|
||||
|
||||
if (docSet.size() > 0)
|
||||
{
|
||||
DeleteUpdateCommand delDocCmd = new DeleteUpdateCommand(request);
|
||||
delDocCmd.setQuery(FIELD_DBID + ":" + dbid);
|
||||
processor.processDelete(delDocCmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isContentIndexedForNode(Map<QName, PropertyValue> properties)
|
||||
|
||||
Reference in New Issue
Block a user