当前位置: 首页>>代码示例>>Java>>正文


Java UpdateResponse类代码示例

本文整理汇总了Java中org.apache.solr.client.solrj.response.UpdateResponse的典型用法代码示例。如果您正苦于以下问题:Java UpdateResponse类的具体用法?Java UpdateResponse怎么用?Java UpdateResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UpdateResponse类属于org.apache.solr.client.solrj.response包,在下文中一共展示了UpdateResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: persistToSolr

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
private void persistToSolr(Collection<SolrInputDocument> docs) throws SolrServerException, IOException {
    if (docs.isEmpty()) {
        /**
         * @todo Throw an exception here? "DvObject id 9999 does not exist."
         */
        logger.info("nothing to persist");
        return;
    }
    logger.fine("persisting to Solr...");
    SolrServer solrServer = new HttpSolrServer("http://" + systemConfig.getSolrHostColonPort() + "/solr");
    /**
     * @todo Do something with these responses from Solr.
     */
    UpdateResponse addResponse = solrServer.add(docs);
    UpdateResponse commitResponse = solrServer.commit();
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:17,代码来源:SolrIndexServiceBean.java

示例2: indexMap

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
public void indexMap(String id, Map<String, List<String>> objectMap)
   throws IOException, SolrServerException {
    SolrInputDocument document = new SolrInputDocument();
    document.addField("id", id);
    for (String key : objectMap.keySet()) {
        Object value = objectMap.get(key);
        if (value != null) {
            // System.err.printf("%s: class: %s\n", key, value.getClass());
            document.addField(key + "_ss", value);
        }
    }

    try {
        UpdateResponse response = solr.add(document);
        // solr.commit();
    } catch (HttpSolrClient.RemoteSolrException ex) {
        System.err.printf("document: %s", document);
        System.err.printf("Commit exception: %s\n", ex.getMessage());
    }
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:21,代码来源:MarcSolrClient.java

示例3: indexDuplumKey

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
public void indexDuplumKey(String id, Map<String, Object> objectMap)
        throws IOException, SolrServerException {
    SolrInputDocument document = new SolrInputDocument();
    document.addField("id", id);
    for (String key : objectMap.keySet()) {
        Object value = objectMap.get(key);
        if (value != null) {
            // System.err.printf("%s: class: %s\n", key, value.getClass());
            document.addField(key + "_ss", value);
        }
    }

    try {
        UpdateResponse response = solr.add(document);
        // solr.commit();
    } catch (HttpSolrClient.RemoteSolrException ex) {
        System.err.printf("document: %s", document);
        System.err.printf("Commit exception: %s\n", ex.getMessage());
    }
}
 
开发者ID:pkiraly,项目名称:metadata-qa-marc,代码行数:21,代码来源:MarcSolrClient.java

示例4: deleteIndex

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
@Override
public synchronized void deleteIndex(BaseSearchBean bean) throws Exception {
    if (bean == null) {
        logger.warn("Get search bean is empty!");
        return;
    }

    String id = bean.getId();

    if (StringUtils.isEmpty(id)) {
        logger.warn("get id and id value from bean is empty!");
        return;
    }

    UpdateResponse response = solrClient.deleteById(id);
    solrClient.commit();

    if (logger.isDebugEnabled()) {
        logger.debug(String.format("delete id '%s', result: '%d' Qtime: '%d'", id, response.getStatus(), response.getQTime()));
    }
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:22,代码来源:SolrSearchEngine.java

示例5: updateDocs

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
private void updateDocs( List<SolrInputDocument> docs, boolean commit ) throws SolrServerException, IOException {
  LOG.debug( "updateDocs " + docs.size( ) );
  SolrClient suggestClient = getSuggestClient( );
  try {
    UpdateResponse resp = suggestClient.add( suggesterCollection, docs );
  }
  catch ( SolrServerException sse ) {
    LOG.error( "Got SolrServerExeption " + sse );
    throw sse;
  }
    
  if (commit) {
    LOG.debug( "committing to " + suggestHost );
    suggestClient.commit( suggesterCollection );
  }
  // check resp - if not OK, throw an Exception??
}
 
开发者ID:detnavillus,项目名称:multifield_suggester_code,代码行数:18,代码来源:SuggestCollectionBuilder.java

示例6: examineFile

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
void examineFile(File file) throws FitsException, IOException, SolrServerException, XMLStreamException {
    System.out.println("Adding " + file.getName());
    FitsOutput fitsOutput = fits.examine(file);
    fitsOutput.addStandardCombinedFormat();

    SolrInputDocument solrDoc = new SolrInputDocument();

    this.indexFitsFileInfo(fitsOutput, solrDoc);
    this.indexFitsIdentities(fitsOutput, solrDoc);
    this.indexTechMetadata(fitsOutput, solrDoc);

    Document fitsXml = fitsOutput.getFitsXml();
    this.indexFitsXml(fitsXml, solrDoc);

    try {
        UpdateResponse response = solr.add(solrDoc);
        solr.commit();
    } catch (HttpSolrClient.RemoteSolrException e) {
        e.printStackTrace();
    }

}
 
开发者ID:little9,项目名称:SolrFits,代码行数:23,代码来源:FitsExaminer.java

示例7: addItemsToIndex

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
@Override
    public void addItemsToIndex(SolrSimilarityConfigurationInt configuration) throws Exception {
        List<Item> items = solrItemDAO.getNonUserItems(configuration);
        // TODO: implement changeDate on items correctly! index from lastRun!!
        for (Item item : items) {
            SolrInputDocument doc = new SolrInputDocument();
            doc.addField("id", item.getTenantId() + item.getItemType() + item.getItemId());
            doc.addField("tenant_i", item.getTenantId());
            doc.addField("type_i", itemTypeDAO.getIdOfType(item.getTenantId(),item.getItemType()));
            doc.addField("id_i", idMappingDAO.lookupOnly(item.getItemId()));
            String all = "";
            Object parsedProfile = configuration.getConfiguration().jsonProvider().parse(item.getProfileData());
            for ( JsonPath jp : configuration.getIndexFields()) {
                all += addFieldToSolrString(jp, parsedProfile);
            }
            doc.addField("all", all);

            UpdateResponse response = solrClient.add(doc);
        }
        
//        logger.info("Response status:" + response.getStatus());
        
        solrClient.commit();
    }
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:25,代码来源:SolrSimilarityServiceImpl.java

示例8: write

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
private void write(final EmbeddedDocument child, final int level, final Document parent, final Document 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 (EmbeddedDocument grandchild : child.getEmbeds()) {
		write(grandchild, level + 1, child, root);
	}
}
 
开发者ID:ICIJ,项目名称:extract,代码行数:21,代码来源:SolrSpewer.java

示例9: addBeans

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
/**
 * Adds the beans supplied by the given iterator.
 * 
 * @param beanIterator
 *          the iterator which returns Beans
 * 
 * @return the response from the SolrServer
 */
public UpdateResponse addBeans(final Iterator<?> beanIterator)
    throws SolrServerException, IOException {
  UpdateRequest req = new UpdateRequest();
  req.setDocIterator(new Iterator<SolrInputDocument>() {
    
    @Override
    public boolean hasNext() {
      return beanIterator.hasNext();
    }
    
    @Override
    public SolrInputDocument next() {
      Object o = beanIterator.next();
      if (o == null) return null;
      return getBinder().toSolrInputDocument(o);
    }
    
    @Override
    public void remove() {
      beanIterator.remove();
    }
  });
  return req.process(this);
}
 
开发者ID:europeana,项目名称:search,代码行数:33,代码来源:HttpSolrServer.java

示例10: runUpdate

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
protected UpdateResponse runUpdate(List<SolrInputDocument> batchToWrite) {
  try {
    UpdateResponse result = solr.add(batchToWrite);
    SolrRecordWriter.incrementCounter(taskId, SolrCounters.class.getName(), SolrCounters.BATCHES_WRITTEN.toString(), 1);      
    SolrRecordWriter.incrementCounter(taskId, SolrCounters.class.getName(), SolrCounters.DOCUMENTS_WRITTEN.toString(), batchToWrite.size());
    if (LOG.isDebugEnabled()) {
      SolrRecordWriter.incrementCounter(taskId, SolrCounters.class.getName(), SolrCounters.BATCH_WRITE_TIME.toString(), result.getElapsedTime());
    }
    return result;
  } catch (Throwable e) {
    if (e instanceof Exception) {
      setBatchWriteException((Exception) e);
    } else {
      setBatchWriteException(new Exception(e));
    }
    SolrRecordWriter.incrementCounter(taskId, getClass().getName() + ".errors", e.getClass().getName(), 1);
    LOG.error("Unable to process batch", e);
    return null;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:BatchWriter.java

示例11: performUpdate

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
private void performUpdate(Delete obj) throws TranslatorException {
	Table table = obj.getTable().getMetadataObject();
	KeyRecord pk = table.getPrimaryKey();
	final String id = getRecordName(pk.getColumns().get(0));

	if (obj.getParameterValues() != null) {
		throw new TranslatorException(SolrPlugin.Event.TEIID20008, SolrPlugin.Util.gs(SolrPlugin.Event.TEIID20008));
	}
	
	SolrQueryExecution query = new SolrQueryExecution(ef, obj, this.executionContext, this.metadata, this.connection);
	query.execute();
	
	final UpdateRequest request = new UpdateRequest();
	query.walkDocuments(new SolrDocumentCallback() {
		@Override
		public void walk(SolrDocument doc) {
			SolrUpdateExecution.this.updateCount++;
			request.deleteById(doc.getFieldValue(id).toString());
		}
	});
	
	UpdateResponse response = this.connection.update(request);
	if (response.getStatus() != 0) {
		throw new TranslatorException(SolrPlugin.Event.TEIID20005, SolrPlugin.Util.gs(SolrPlugin.Event.TEIID20005, response.getStatus()));
	}		
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:27,代码来源:SolrUpdateExecution.java

示例12: writeToIndex

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
/**
 * @param doc
 * @return Error message, if occurred; null otherwise.
 * @throws FatalIndexerException
 * @should write doc correctly
 */
public boolean writeToIndex(SolrInputDocument doc) throws FatalIndexerException {
    boolean success = false;
    int tries = RETRY_ATTEMPTS;

    while (!success && tries > 0) {
        tries--;
        try {
            UpdateResponse ur = server.add(doc);
            switch (ur.getStatus()) {
                case 0:
                    success = true;
                    break;
                default:
                    logger.error("Update status: {}", ur.getStatus());
            }
            return true;
        } catch (SolrServerException | IOException e) {
            logger.error(e.getMessage(), e);
        }
    }

    if (!success) {
        logger.error("Could not write document after {} attempts. Check the Solr server connection. Exiting...", RETRY_ATTEMPTS);
        rollback();
        throw new FatalIndexerException("Solr connection error");
    }

    return false;
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:36,代码来源:SolrHelper.java

示例13: simpleWrite

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
/**
 * Write a document using the SolrTemplate
 */
@Test
@SuppressWarnings("unchecked")
public void simpleWrite() throws Exception {
    DiscoSolrDocument doc = discoDocument("1", "simpleWriteWithTemplate");

    // NOT TRUE WITH spring-data-solr 3: Don't need to use the saveBean(core, doc) method, because the document has the core as an annotation
    UpdateResponse res = solrTemplate.saveBean("discos", doc);
    assertNotNull(res);

    solrTemplate.commit("discos");
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:15,代码来源:SimpleSolrIT.java

示例14: writeAndUpdateDiscoDocUsingPartialUpdate

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
@Test
public void writeAndUpdateDiscoDocUsingPartialUpdate() throws Exception {
    String solrCore = "discos";
    long expectedDocId = 200L;
    DiscoSolrDocument doc = new DiscoSolrDocument.Builder()
            .docId(String.valueOf(expectedDocId))
            .discoUri("http://doi.org/10.1109/disco/2")
            .discoStatus("ACTIVE")
            .build();

    UpdateResponse res = solrTemplate.saveBean(solrCore, doc);
    assertNotNull(res);
    assertEquals(0, res.getStatus());
    solrTemplate.commit(solrCore);


    assertEquals(doc, solrTemplate.getById(solrCore, expectedDocId, DiscoSolrDocument.class)
            .orElseThrow(() -> new RuntimeException(
                    "Expected to find a DiscoSolrDocument with ID " + doc.getDocId() + " in the index.")));

    // Update using Solr Atomic Updates (requires <updateLog/>)
    PartialUpdate update = new PartialUpdate(DiscoSolrDocument.DOC_ID, doc.getDocId());
    update.setValueOfField(DiscoSolrDocument.DISCO_STATUS, "INACTIVE");
    res = solrTemplate.saveBean(solrCore, update);
    assertNotNull(res);
    assertEquals(0, res.getStatus());
    solrTemplate.commit(solrCore);

    assertEquals("INACTIVE", solrTemplate.getById(solrCore, expectedDocId, DiscoSolrDocument.class)
            .orElseThrow(() -> new RuntimeException(
                    "Expected to find a DiscoSolrDocument with ID " + doc.getDocId() + " in the index."))
            .getDiscoStatus());
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:34,代码来源:SimpleSolrIT.java

示例15: index

import org.apache.solr.client.solrj.response.UpdateResponse; //导入依赖的package包/类
@Override
public void index() throws IOException, SolrServerException {
    LOGGER.info("Sending optimize request to solr");
    UpdateResponse response = getSolrClient().optimize();
    LOGGER.info(MessageFormat.format("Optimize was {0}({1}ms)",
        (response.getStatus() == 0 ? "successful." : "UNSUCCESSFUL!"), response.getElapsedTime()));
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:8,代码来源:MCRSolrOptimizeIndexHandler.java


注:本文中的org.apache.solr.client.solrj.response.UpdateResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。