org.apache.solr.client.solrj.response.UpdateResponse Java Examples

The following examples show how to use org.apache.solr.client.solrj.response.UpdateResponse. 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: SolrSearchServer.java    From vind with Apache License 2.0 6 votes vote down vote up
private IndexResult indexSingleDocument(Document doc, int withinMs) {
    final SolrInputDocument document = createInputDocument(doc);
    try {
        if (solrClientLogger.isTraceEnabled()) {
            solrClientLogger.debug(">>> add({}): {}", doc.getId(), ClientUtils.toXML(document));
        } else {
            solrClientLogger.debug(">>> add({})", doc.getId());
        }

        removeNonParentDocument(doc, withinMs);
        final UpdateResponse response = withinMs < 0 ? this.solrClient.add(document) : this.solrClient.add(document, withinMs);
        return new IndexResult(Long.valueOf(response.getQTime())).setElapsedTime(response.getElapsedTime());

    } catch (SolrServerException | IOException e) {
        log.error("Cannot index document {}", document.getField(ID) , e);
        throw new SearchServerException("Cannot index document", e);
    }
}
 
Example #2
Source File: SolrControllerTest.java    From Spring-Boot-Book with Apache License 2.0 6 votes vote down vote up
@Test
public void delById()  throws IOException, SolrServerException {
    //根据id删除信息
    UpdateResponse updateResponse = solrClient.deleteById("8888888");
    //执行的时间
    long elapsedTime = updateResponse.getElapsedTime();
    int qTime = updateResponse.getQTime();
    //请求地址
    String requestUrl = updateResponse.getRequestUrl();
    //请求的结果{responseHeader={status=0,QTime=2}}
    NamedList<Object> response = updateResponse.getResponse();
    //请求结果的头{status=0,QTime=2}
    NamedList responseHeader = updateResponse.getResponseHeader();
    //请求的状态 0
    solrClient.commit();
    int status = updateResponse.getStatus();
    //成功则返回0.要是没有文档被删除也会返回0,代表根本没有

}
 
Example #3
Source File: SolrLocatorTest.java    From kite with Apache License 2.0 6 votes vote down vote up
@Test
public void testSelectsEmbeddedSolrServerAndAddDocument() throws Exception {
  //Solr locator should select EmbeddedSolrServer only solrHome is specified
  SolrLocator solrLocator = new SolrLocator(new SolrMorphlineContext.Builder().build());
  solrLocator.setSolrHomeDir(RESOURCES_DIR + "/solr");
  solrLocator.setCollectionName("collection1");

  SolrServerDocumentLoader documentLoader = (SolrServerDocumentLoader)solrLocator.getLoader();
  SolrClient solrServer = documentLoader.getSolrServer();
  
  assertTrue(solrServer instanceof EmbeddedSolrServer);
  
  SolrInputDocument doc = new SolrInputDocument();
  doc.addField("id", "myId");
  doc.addField("text", "myValue");
  solrServer.add(doc);
  solrServer.commit();
  
  SolrDocument resultDoc = solrServer.getById("myId");
  assertTrue(resultDoc.getFieldValues("text").contains("myValue"));
  
  UpdateResponse deleteResponse = solrServer.deleteById("myId");
  assertEquals(0, deleteResponse.getStatus());
  solrServer.commit();
  solrServer.close();
}
 
Example #4
Source File: TestStressInPlaceUpdates.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
protected long deleteDocAndGetVersion(String id, ModifiableSolrParams params, boolean deleteByQuery) throws Exception {
  params.add("versions", "true");
 
  UpdateRequest ureq = new UpdateRequest();
  ureq.setParams(params);
  if (deleteByQuery) {
    ureq.deleteByQuery("id:"+id);
  } else {
    ureq.deleteById(id);
  }
  UpdateResponse resp;
  // send updates to leader, to avoid SOLR-8733
  resp = ureq.process(leaderClient);
  
  String key = deleteByQuery? "deleteByQuery": "deletes";
  long returnedVersion = Long.parseLong(((NamedList) resp.getResponse().get(key)).getVal(0).toString());
  assertTrue("Due to SOLR-8733, sometimes returned version is 0. Let us assert that we have successfully"
      + " worked around that problem here.", returnedVersion < 0);
  return returnedVersion;
}
 
Example #5
Source File: SolrSpewer.java    From extract with MIT License 6 votes vote down vote up
private void write(final EmbeddedTikaDocument child, final int level, final TikaDocument parent, final TikaDocument root)
		throws IOException {
	final SolrInputDocument inputDocument = prepareDocument(child, level, parent, root);
	final UpdateResponse response;

	// Free up memory.
	child.clearReader();

	// Null is a signal to skip.
	if (null == inputDocument) {
		return;
	}

	response = write(child, inputDocument);
	logger.info("Child document added to Solr in {}ms: \"{}\".", response.getElapsedTime(), child);

	for (EmbeddedTikaDocument grandchild : child.getEmbeds()) {
		write(grandchild, level + 1, child, root);
	}
}
 
Example #6
Source File: TestStressInPlaceUpdates.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
protected long addDocAndGetVersion(Object... fields) throws Exception {
  SolrInputDocument doc = new SolrInputDocument();
  addFields(doc, fields);

  ModifiableSolrParams params = new ModifiableSolrParams();
  params.add("versions", "true");

  UpdateRequest ureq = new UpdateRequest();
  ureq.setParams(params);
  ureq.add(doc);
  UpdateResponse resp;

  // send updates to leader, to avoid SOLR-8733
  resp = ureq.process(leaderClient);

  long returnedVersion = Long.parseLong(((NamedList) resp.getResponse().get("adds")).getVal(0).toString());
  assertTrue("Due to SOLR-8733, sometimes returned version is 0. Let us assert that we have successfully"
      + " worked around that problem here.", returnedVersion > 0);
  return returnedVersion;
}
 
Example #7
Source File: SolrSearchServer.java    From vind with Apache License 2.0 6 votes vote down vote up
@Override
public DeleteResult deleteWithin(Document doc, int withinMs) {
    try {
        long qTime = 0;
        long elapsedTime = 0;
        solrClientLogger.debug(">>> delete({})", doc.getId());
        final UpdateResponse deleteResponse = withinMs < 0 ? solrClient.deleteById(doc.getId()) : solrClient.deleteById(doc.getId(), withinMs);
        qTime = deleteResponse.getQTime();
        elapsedTime = deleteResponse.getElapsedTime();
        //Deleting nested documents
        final UpdateResponse deleteNestedResponse = withinMs < 0 ? solrClient.deleteByQuery("_root_:" + doc.getId()) : solrClient.deleteByQuery("_root_:" + doc.getId(), withinMs);
        qTime += deleteNestedResponse.getQTime();
        elapsedTime += deleteNestedResponse.getElapsedTime();

        return new DeleteResult(qTime).setElapsedTime(elapsedTime);
    } catch (SolrServerException | IOException e) {
        log.error("Cannot delete document {}", doc.getId() , e);
        throw new SearchServerException("Cannot delete document", e);
    }
}
 
Example #8
Source File: SolrSearchServer.java    From vind with Apache License 2.0 6 votes vote down vote up
@Override
public DeleteResult execute(Delete delete, DocumentFactory factory) {
    String query = SolrUtils.Query.buildFilterString(delete.getQuery(), factory, delete.getUpdateContext(),true);
    try {
        solrClientLogger.debug(">>> delete query({})", query);

        final UpdateResponse deleteChildrenResponse =
                solrClient.deleteByQuery(
                        String.format("{!child of='_type_:%s' v='%s'}",
                                factory.getType(),
                                query.trim().replaceAll("'","\"")));
        long qTime = deleteChildrenResponse.getQTime();
        long elapsedTime = deleteChildrenResponse.getElapsedTime();
        final UpdateResponse deleteResponse = solrClient.deleteByQuery(query.trim().replaceAll("^\\+",""));
        qTime += deleteResponse.getQTime();
        elapsedTime += deleteResponse.getElapsedTime();

        return new DeleteResult(qTime).setElapsedTime(elapsedTime);
    } catch (SolrServerException | IOException e) {
        log.error("Cannot delete with query {}", query, e);
        throw new SearchServerException("Cannot delete with query", e);
    }
}
 
Example #9
Source File: SolrStorageEngineTest.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@Test
public void storeOntologyEntries_responseOkay() throws Exception {
	final int commitWithMs = 60000;
	final SolrConfiguration config = mock(SolrConfiguration.class);
	when(config.getCommitWithinMs()).thenReturn(commitWithMs);
	
	OntologyEntryBean bean = mock(OntologyEntryBean.class);
	List<OntologyEntryBean> beans = Arrays.asList(bean);
	
	UpdateResponse response = mock(UpdateResponse.class);
	when(response.getStatus()).thenReturn(SolrStorageEngine.STATUS_OK);
	
	SolrClient server = mock(SolrClient.class);
	when(server.addBeans(beans, commitWithMs)).thenReturn(response);
	
	SolrStorageEngine engine = new SolrStorageEngine(config, server);
	engine.storeOntologyEntries(beans);
	
	verify(server).addBeans(beans, commitWithMs);
	verify(response).getStatus();
}
 
Example #10
Source File: SolrLookingBlurServer.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
@Override
public UpdateResponse deleteById(final List<String> ids) throws SolrServerException, IOException {
  return respond(UpdateResponse.class, new Command() {
    public void process() throws Exception {
      if (ids.size() == 1) {
        client().mutate(toDeleteMutation(ids.get(0)));
      } else {
        List<RowMutation> mutates = Lists.newArrayList();
        for (String id : ids) {
          mutates.add(toDeleteMutation(id));
        }
        client().mutateBatch(mutates);
      }
    }
  });
}
 
Example #11
Source File: JsonQueryRequestIntegrationTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setupCluster() throws Exception {
  configureCluster(1)
      .addConfig(CONFIG_NAME, new File(ExternalPaths.TECHPRODUCTS_CONFIGSET).toPath())
      .configure();

  final List<String> solrUrls = new ArrayList<>();
  solrUrls.add(cluster.getJettySolrRunner(0).getBaseUrl().toString());

  CollectionAdminRequest.createCollection(COLLECTION_NAME, CONFIG_NAME, 1, 1).process(cluster.getSolrClient());

  ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");
  up.setParam("collection", COLLECTION_NAME);
  up.addFile(getFile("solrj/books.csv"), "application/csv");
  up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
  UpdateResponse updateResponse = up.process(cluster.getSolrClient());
  assertEquals(0, updateResponse.getStatus());
}
 
Example #12
Source File: MarcSolrClient.java    From metadata-qa-marc with GNU General Public License v3.0 6 votes vote down vote up
public void indexDuplumKey(String id, Map<String, Object> objectMap)
    throws IOException, SolrServerException {
  SolrInputDocument document = new SolrInputDocument();
  document.addField("id", id);
  for (Map.Entry<String, Object> entry : objectMap.entrySet()) {
    String key = entry.getKey();
    Object value = entry.getValue();
    if (value != null) {
      if (!key.endsWith("_sni") && !key.endsWith("_ss"))
        key += "_ss";
      document.addField(key, value);
    }
  }

  try {
    UpdateResponse response = solr.add(document);
  } catch (HttpSolrClient.RemoteSolrException ex) {
    System.err.printf("document: %s", document);
    System.err.printf("Commit exception: %s%n", ex.getMessage());
  }
}
 
Example #13
Source File: MarcSolrClient.java    From metadata-qa-marc with GNU General Public License v3.0 6 votes vote down vote up
public void indexMap(String id, Map<String, List<String>> objectMap)
    throws IOException, SolrServerException {
  SolrInputDocument document = new SolrInputDocument();
  document.addField("id", (trimId ? id.trim() : id));
  for (Map.Entry<String, List<String>> entry : objectMap.entrySet()) {
    String key = entry.getKey();
    Object value = entry.getValue();
    if (value != null) {
      if (!key.endsWith("_sni") && !key.endsWith("_ss"))
        key += "_ss";
      document.addField(key, value);
    }
  }

  try {
    UpdateResponse response = solr.add(document);
  } catch (HttpSolrClient.RemoteSolrException ex) {
    System.err.printf("document: %s", document);
    System.err.printf("Commit exception: %s%n", ex.getMessage());
  }
}
 
Example #14
Source File: SolrTemplate.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public void commit() {
	execute(new SolrCallback<UpdateResponse>() {
		@Override
		public UpdateResponse doInSolr(SolrClient solrClient) throws SolrServerException, IOException {
			return solrClient.commit();
		}
	});
}
 
Example #15
Source File: PutSolrRecord.java    From nifi with Apache License 2.0 5 votes vote down vote up
private void index(boolean isSolrCloud, String collection, Long commitWithin, String contentStreamPath, MultiMapSolrParams requestParams, List<SolrInputDocument> inputDocumentList)
        throws IOException, SolrServerException,SolrException {
    UpdateRequest request = new UpdateRequest(contentStreamPath);
    request.setParams(new ModifiableSolrParams());

    // add the extra params, don't use 'set' in case of repeating params
    Iterator<String> paramNames = requestParams.getParameterNamesIterator();
    while (paramNames.hasNext()) {
        String paramName = paramNames.next();
        for (String paramValue : requestParams.getParams(paramName)) {
            request.getParams().add(paramName, paramValue);
        }
    }

    // specify the collection for SolrCloud
    if (isSolrCloud) {
        request.setParam(COLLECTION_PARAM_NAME, collection);
    }

    if (commitWithin != null && commitWithin > 0) {
        request.setParam(COMMIT_WITHIN_PARAM_NAME, commitWithin.toString());
    }

    // if a username and password were provided then pass them for basic auth
    if (isBasicAuthEnabled()) {
        request.setBasicAuthCredentials(getUsername(), getPassword());
    }
    request.add(inputDocumentList);
    UpdateResponse response = request.process(getSolrClient());
    getLogger().debug("Got {} response from Solr", new Object[]{response.getStatus()});
    inputDocumentList.clear();
}
 
Example #16
Source File: SolrTemplate.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public UpdateResponse deleteById(Collection<String> ids) {
	Assert.notNull(ids, "Cannot delete 'null' collection.");

	final List<String> toBeDeleted = new ArrayList<String>(ids);
	return execute(new SolrCallback<UpdateResponse>() {
		@Override
		public UpdateResponse doInSolr(SolrClient solrClient) throws SolrServerException, IOException {
			return solrClient.deleteById(toBeDeleted);
		}
	});
}
 
Example #17
Source File: SolrLookingBlurServer.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
@Override
public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher, final int maxSegments)
    throws SolrServerException,
    IOException {
  return respond(UpdateResponse.class, new Command() {
    public void process() throws Exception {
      client().optimize(tableName, maxSegments);
    }
  });
}
 
Example #18
Source File: SolrServerDocumentLoader.java    From kite with Apache License 2.0 5 votes vote down vote up
@Override
public UpdateResponse rollbackTransaction() throws SolrServerException, IOException {
  LOGGER.trace("rollback");
  SolrClient s = getNonRetryingSolrServer();
  if (!(s instanceof CloudSolrClient)) {
    return server.rollback();
  } else {
    return new UpdateResponse();
  }
}
 
Example #19
Source File: StreamlineSolrJsonMapper.java    From streamline with Apache License 2.0 5 votes vote down vote up
private SolrRequest<UpdateResponse> createSolrRequest(String json) {
    final ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(jsonUpdateUrl);
    final ContentStream cs = new ContentStreamBase.StringStream(json, CONTENT_TYPE);
    request.addContentStream(cs);
    LOG.debug("Request generated with JSON: {}", json);
    return request;
}
 
Example #20
Source File: OverseerCollectionMessageHandler.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked"})
void commit(@SuppressWarnings({"rawtypes"})NamedList results, String slice, Replica parentShardLeader) {
  log.debug("Calling soft commit to make sub shard updates visible");
  String coreUrl = new ZkCoreNodeProps(parentShardLeader).getCoreUrl();
  // HttpShardHandler is hard coded to send a QueryRequest hence we go direct
  // and we force open a searcher so that we have documents to show upon switching states
  UpdateResponse updateResponse = null;
  try {
    updateResponse = softCommit(coreUrl);
    processResponse(results, null, coreUrl, updateResponse, slice, Collections.emptySet());
  } catch (Exception e) {
    processResponse(results, e, coreUrl, updateResponse, slice, Collections.emptySet());
    throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to call distrib softCommit on: " + coreUrl, e);
  }
}
 
Example #21
Source File: MergingSolrSpewer.java    From extract with MIT License 5 votes vote down vote up
@Override
protected UpdateResponse write(final TikaDocument tikaDocument, final SolrInputDocument inputDocument) throws
		IOException {

	// Only root documents are merged.
	if (tikaDocument instanceof EmbeddedTikaDocument) {
		return super.write(tikaDocument, inputDocument);
	} else {
		return write(tikaDocument, inputDocument, retries);
	}
}
 
Example #22
Source File: DbToSolrMigrationUtil.java    From ranger with Apache License 2.0 5 votes vote down vote up
public void send2solr(XXAccessAuditV5 xXAccessAudit) throws Throwable {
	SolrInputDocument document = new SolrInputDocument();
	toSolrDocument(xXAccessAudit,document);
	UpdateResponse response = solrClient.add(document);
	if (response.getStatus() != 0) {
		logger.info("Response=" + response.toString() + ", status= "
				+ response.getStatus() + ", event=" + xXAccessAudit.toString());
		throw new Exception("Failed to send audit event ID=" + xXAccessAudit.getId());
	}
}
 
Example #23
Source File: CloudSolrSinkTask.java    From kafka-connect-solr with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(String topic, UpdateRequest updateRequest) throws IOException, SolrServerException {
  final String collection = collection(topic);
  updateRequest.setParam("collection", collection);
  UpdateResponse response = updateRequest.process(client);
  log.trace("process() - qtime = {} elapsedTime = {}", response.getQTime(), response.getElapsedTime());
}
 
Example #24
Source File: RoutedAliasUpdateProcessorTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/** Adds the docs to Solr via {@link #getSolrClient()} with the params */
@SuppressWarnings("SameParameterValue")
protected UpdateResponse add(String collection, Collection<SolrInputDocument> docs, SolrParams params) throws SolrServerException, IOException {
  UpdateRequest req = new UpdateRequest();
  if (params != null) {
    req.setParams(new ModifiableSolrParams(params));// copy because will be modified
  }
  req.add(docs);
  return req.process(getSolrClient(), collection);
}
 
Example #25
Source File: TestInPlaceUpdatesDistrib.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public UpdateResponse call() throws Exception {
  UpdateResponse resp = update.process(solrClient); //solrClient.request(update);
  if (rnd.nextInt(commitBound) == 0)
    solrClient.commit();
  return resp;
}
 
Example #26
Source File: SolrLookingBlurServer.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
@Override
public UpdateResponse add(final Collection<SolrInputDocument> docs) throws SolrServerException, IOException {
  return respond(UpdateResponse.class, new Command() {
    public void process() throws Exception {
      if (docs.size() == 1) {
        client().mutate(RowMutationHelper.from(docs.iterator().next(), tableName));
      } else {
        client().mutateBatch(RowMutationHelper.from(docs, tableName));
      }
    }
  });
}
 
Example #27
Source File: MCRSolrIndexer.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Convenient method to delete a derivate and all its files at once.
 *
 * @param id the derivate id
 * @return the solr response
 */
public static UpdateResponse deleteDerivate(SolrClient solrClient, String id) {
    if (id == null) {
        return null;
    }
    UpdateResponse updateResponse = null;
    long start = System.currentTimeMillis();
    try {
        LOGGER.debug("Deleting derivate \"{}\" from solr", id);
        UpdateRequest req = new UpdateRequest();
        StringBuilder deleteQuery = new StringBuilder();
        deleteQuery.append("id:").append(id).append(" ");
        deleteQuery.append("derivateID:").append(id);
        if (MCRSolrUtils.useNestedDocuments()) {
            deleteQuery.append(" ").append("_root_:").append(id);
        }
        req.deleteByQuery(deleteQuery.toString());
        updateResponse = req.process(solrClient);
        solrClient.commit();
    } catch (Exception e) {
        LOGGER.error("Error deleting document from solr", e);
    }
    long end = System.currentTimeMillis();
    MCRSolrIndexStatistic operations = MCRSolrIndexStatisticCollector.OPERATIONS;
    operations.addDocument(1);
    operations.addTime(end - start);
    return updateResponse;
}
 
Example #28
Source File: DirectJsonQueryRequestFacetingEmbeddedTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
  final String sourceHome = ExternalPaths.SOURCE_HOME;

  final File tempSolrHome = LuceneTestCase.createTempDir().toFile();
  FileUtils.copyFileToDirectory(new File(sourceHome, "server/solr/solr.xml"), tempSolrHome);
  final File collectionDir = new File(tempSolrHome, COLLECTION_NAME);
  FileUtils.forceMkdir(collectionDir);
  final File configSetDir = new File(sourceHome, "server/solr/configsets/sample_techproducts_configs/conf");
  FileUtils.copyDirectoryToDirectory(configSetDir, collectionDir);

  final Properties props = new Properties();
  props.setProperty("name", COLLECTION_NAME);

  try (Writer writer = new OutputStreamWriter(FileUtils.openOutputStream(new File(collectionDir, "core.properties")),
      "UTF-8");) {
    props.store(writer, null);
  }

  final String config = tempSolrHome.getAbsolutePath() + "/" + COLLECTION_NAME + "/conf/solrconfig.xml";
  final String schema = tempSolrHome.getAbsolutePath() + "/" + COLLECTION_NAME + "/conf/managed-schema";
  initCore(config, schema, tempSolrHome.getAbsolutePath(), COLLECTION_NAME);

  client = new EmbeddedSolrServer(h.getCoreContainer(), COLLECTION_NAME) {
    @Override
    public void close() {
      // do not close core container
    }
  };

  ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");
  up.setParam("collection", COLLECTION_NAME);
  up.addFile(getFile("solrj/techproducts.xml"), "application/xml");
  up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
  UpdateResponse updateResponse = up.process(client);
  assertEquals(0, updateResponse.getStatus());
}
 
Example #29
Source File: MCRSolrInputDocumentsHandler.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void index() throws IOException, SolrServerException {
    if (documents == null || documents.isEmpty()) {
        LOGGER.warn("No input documents to index.");
        return;
    }
    int totalCount = documents.size();
    LOGGER.info("Handling {} documents", totalCount);
    SolrClient solrClient = getSolrClient();
    if (solrClient instanceof ConcurrentUpdateSolrClient) {
        LOGGER.info("Detected ConcurrentUpdateSolrClient. Split up batch update.");
        splitDocuments();
        //for statistics:
        documents.clear();
        return;
    }
    UpdateResponse updateResponse;
    try {
        UpdateRequest updateRequest = getUpdateRequest(MCRSolrConstants.SOLR_UPDATE_PATH);
        updateRequest.add(documents);
        updateResponse = updateRequest.process(getSolrClient());
    } catch (Throwable e) {
        LOGGER.warn("Error while indexing document collection. Split and retry.");
        splitDocuments();
        return;
    }
    if (updateResponse.getStatus() != 0) {
        LOGGER.error("Error while indexing document collection. Split and retry: {}", updateResponse.getResponse());
        splitDocuments();
    } else {
        LOGGER.info("Sending {} documents was successful in {} ms.", totalCount, updateResponse.getElapsedTime());
    }
}
 
Example #30
Source File: MCRSolrOptimizeIndexHandler.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void index() throws IOException, SolrServerException {
    LOGGER.info("Sending optimize request to solr");
    UpdateResponse response = getSolrClient().optimize();
    LOGGER.info("Optimize was {}({}ms)", (response.getStatus() == 0 ? "successful." : "UNSUCCESSFUL!"),
        response.getElapsedTime());
}