Java Code Examples for org.apache.solr.update.processor.UpdateRequestProcessor#processDelete()

The following examples show how to use org.apache.solr.update.processor.UpdateRequestProcessor#processDelete() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SolrInformationServer.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void deleteByQuery(String query) throws IOException
{
    UpdateRequestProcessor processor = null;
    try (SolrQueryRequest request = newSolrQueryRequest())
    {
        processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse());
        DeleteUpdateCommand delDocCmd = new DeleteUpdateCommand(request);
        delDocCmd.setQuery(query);
        processor.processDelete(delDocCmd);
    }
    finally
    {
        if (processor != null)
        {
            processor.finish();
        }
    }
}
 
Example 2
Source File: SolrInformationServer.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void deleteErrorNode(UpdateRequestProcessor processor, SolrQueryRequest request, Node node) throws IOException
{
    String errorDocId = PREFIX_ERROR + node.getId();
    if (getDocListSize(FIELD_SOLR4_ID + ":" + errorDocId) > 0)
    {
        DeleteUpdateCommand delErrorDocCmd = new DeleteUpdateCommand(request);
        delErrorDocCmd.setId(errorDocId);
        processor.processDelete(delErrorDocCmd);
    }
}
 
Example 3
Source File: SolrInformationServer.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void deleteNode(UpdateRequestProcessor processor, SolrQueryRequest request, long dbid) throws IOException
{
    if (getDocListSize(FIELD_DBID + ":" + dbid) > 0)
    {
        DeleteUpdateCommand delDocCmd = new DeleteUpdateCommand(request);
        delDocCmd.setQuery(FIELD_DBID + ":" + dbid);
        processor.processDelete(delDocCmd);
    }
}
 
Example 4
Source File: JavabinLoader.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private void delete(SolrQueryRequest req, UpdateRequest update, UpdateRequestProcessor processor) throws IOException {
  SolrParams params = update.getParams();
  DeleteUpdateCommand delcmd = new DeleteUpdateCommand(req);
  if(params != null) {
    delcmd.commitWithin = params.getInt(UpdateParams.COMMIT_WITHIN, -1);
  }
  
  if(update.getDeleteByIdMap() != null) {
    Set<Entry<String,Map<String,Object>>> entries = update.getDeleteByIdMap().entrySet();
    for (Entry<String,Map<String,Object>> e : entries) {
      delcmd.id = e.getKey();
      Map<String,Object> map = e.getValue();
      if (map != null) {
        Long version = (Long) map.get("ver");
        if (version != null) {
          delcmd.setVersion(version);
        }
      }
      if (map != null) {
        String route = (String) map.get(ShardParams._ROUTE_);
        if (route != null) {
          delcmd.setRoute(route);
        }
      }
      processor.processDelete(delcmd);
      delcmd.clear();
    }
  }
  
  if(update.getDeleteQuery() != null) {
    for (String s : update.getDeleteQuery()) {
      delcmd.query = s;
      processor.processDelete(delcmd);
    }
  }
}
 
Example 5
Source File: ChronixRetentionHandler.java    From chronix.server with Apache License 2.0 2 votes vote down vote up
/**
 * Triggers the deletion
 *
 * @param processor the update processor do process deletions
 * @param req       the solr query request information
 * @throws IOException if bad things happen
 */
private void deleteOldDocuments(String deletionQuery, UpdateRequestProcessor processor, SolrQueryRequest req) throws IOException {
    DeleteUpdateCommand delete = new DeleteUpdateCommand(req);
    delete.setQuery(deletionQuery);
    processor.processDelete(delete);
}