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


Java UpdateRequest.process方法代码示例

本文整理汇总了Java中org.apache.solr.client.solrj.request.UpdateRequest.process方法的典型用法代码示例。如果您正苦于以下问题:Java UpdateRequest.process方法的具体用法?Java UpdateRequest.process怎么用?Java UpdateRequest.process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.client.solrj.request.UpdateRequest的用法示例。


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

示例1: indexAndCommitOneDocument

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
/**
 * Indexiert das übergebene Dokument und übernimmt die Änderungen in den Solr-Index
 * durch das Ausführen eines Commits.
 *
 * @param gutenbergDoc das zu indexierende Dokument
 */
public void indexAndCommitOneDocument(GutenbergDoc gutenbergDoc) {
    SolrInputDocument document = buildSolrDoc(gutenbergDoc);

    UpdateRequest updateRequest = new UpdateRequest();
    updateRequest.setBasicAuthCredentials(USERNAME, PASSWORD);
    updateRequest.add(document);
    updateRequest.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, false);

    try {
        updateRequest.process(solrClient);
        System.out.println("Dokument " + gutenbergDoc.getDocId() + " erfolgreich indexiert!");
    }
    catch (SolrServerException|IOException e) {
        System.err.println("Fehler bei der Indexierung des Dokuments " + gutenbergDoc.getDocId() + ": " + e.getMessage());
        updateRequest.rollback();
    }
}
 
开发者ID:saschaszott,项目名称:suma-tech,代码行数:24,代码来源:SolrIndexer.java

示例2: indexDocumentsAndCommit

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
/**
 * Indexiert die übergebene Liste von Dokumenten und führt am Ende ein Commit durch.
 *
 * Tritt während der Indexierung ein Fehler auf, so werden die Änderungen nicht
 * zurückgenommen, die bereits erfolgreich in den Solr-Index geschrieben werden konnten.
 *
 * @param gutenbergDocs die Liste der zu indexierenden Dokumente
 */
public void indexDocumentsAndCommit(List<GutenbergDoc> gutenbergDocs) {
    UpdateRequest updateRequest = new UpdateRequest();
    updateRequest.setBasicAuthCredentials(USERNAME, PASSWORD);
    for (GutenbergDoc gutenbergDoc : gutenbergDocs) {
        SolrInputDocument solrInputDocument = buildSolrDoc(gutenbergDoc);
        if (gutenbergDoc.getDocId().equals("9")) {
            // füge zu Dokument 9 ein Feld hinzu, dass es nicht im Solr-Schema gibt
            solrInputDocument.addField("foo", "bar");
        }
        updateRequest.add(solrInputDocument);
    }
    updateRequest.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, false);

    try {
        updateRequest.process(solrClient);
        System.out.println(gutenbergDocs.size() + " Dokumente erfolgreich indexiert!");
    }
    catch (SolrServerException|IOException e) {
        System.err.println("Fehler bei der Indexierung der Dokumente: " + e.getMessage());
        updateRequest.rollback();
    }
}
 
开发者ID:saschaszott,项目名称:suma-tech,代码行数:31,代码来源:SolrIndexer.java

示例3: indexAndCommitDocuments

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
/**
 * Indexiert die übergebene Liste von Dokumenten und führt nach jedem Dokument einen Commit durch.
 *
 * Tritt während der Indexierung eines Dokuments ein Fehler auf, so gehen die zuvor bereits
 * erfolgreich indexierten Dokumente nicht verloren.
 *
 * @param gutenbergDocs die Liste der zu indexierenden Dokumente
 */
public void indexAndCommitDocuments(List<GutenbergDoc> gutenbergDocs) {
    for (GutenbergDoc gutenbergDoc : gutenbergDocs) {
        UpdateRequest updateRequest = new UpdateRequest();
        updateRequest.setBasicAuthCredentials(USERNAME, PASSWORD);

        SolrInputDocument solrInputDocument = buildSolrDoc(gutenbergDoc);
        if (gutenbergDoc.getDocId().equals("9")) {
            // füge zu Dokument 9 ein Feld hinzu, dass es nicht im Solr-Schema gibt
            solrInputDocument.addField("foo", "bar");
        }
        updateRequest.add(solrInputDocument);
        updateRequest.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, false);

        try {
            updateRequest.process(solrClient);
            System.out.println("Dokument " + gutenbergDoc.getDocId() + " erfolgreich indexiert!");
        }
        catch (SolrServerException|IOException e) {
            System.err.println("Fehler bei der Indexierung der Dokumente: " + e.getMessage());
            updateRequest.rollback();
        }
    }
}
 
开发者ID:saschaszott,项目名称:suma-tech,代码行数:32,代码来源:SolrIndexer.java

示例4: indexAndCommitOneDocument

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
/**
 * Indexiert das übergebene Gutenberg-Dokument und übernimmt die Änderungen in den Solr-Index
 * durch das Ausführen eines Commits.
 *
 * @param gutenbergDoc das zu indexierende Dokument
 */
private void indexAndCommitOneDocument(GutenbergDoc gutenbergDoc) {
    SolrInputDocument document = buildSolrDoc(gutenbergDoc);

    UpdateRequest updateRequest = new UpdateRequest();
    updateRequest.setBasicAuthCredentials(Configuration.USERNAME, Configuration.PASSWORD);
    updateRequest.add(document);
    updateRequest.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, false);

    try {
        updateRequest.process(solrClient);
        System.out.println("Dokument " + gutenbergDoc.getDocId() + " erfolgreich indexiert!");
    }
    catch (SolrServerException|IOException e) {
        System.err.println("Fehler bei der Indexierung des Dokuments " + gutenbergDoc.getDocId() + ": " + e.getMessage());
        updateRequest.rollback();
    }
}
 
开发者ID:saschaszott,项目名称:suma-tech,代码行数:24,代码来源:SolrIndexerComplete.java

示例5: close

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
public void close() throws IOException {
  try {
    if (!inputDocs.isEmpty()) {
      LOG.info("Indexing " + Integer.toString(inputDocs.size()) + " documents");
      if (numDeletes > 0) {
        LOG.info("Deleting " + Integer.toString(numDeletes) + " documents");
      }
      UpdateRequest req = new UpdateRequest();
      req.add(inputDocs);
      req.setParams(params);
      req.process(solr);
      inputDocs.clear();
    }
    // solr.commit();
  } catch (final SolrServerException e) {
    throw makeIOException(e);
  }
}
 
开发者ID:yahoo,项目名称:anthelion,代码行数:19,代码来源:SolrWriter.java

示例6: indexDoc

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
protected void indexDoc(List<CloudJettyRunner> skipServers, Object... fields) throws IOException,
    SolrServerException {
  SolrInputDocument doc = new SolrInputDocument();
  
  addFields(doc, fields);
  addFields(doc, "rnd_b", true);
  
  controlClient.add(doc);
  
  UpdateRequest ureq = new UpdateRequest();
  ureq.add(doc);
  ModifiableSolrParams params = new ModifiableSolrParams();
  for (CloudJettyRunner skip : skipServers) {
    params.add("test.distrib.skip.servers", skip.url + "/");
  }
  ureq.setParams(params);
  ureq.process(cloudClient);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:SyncSliceTest.java

示例7: testChineseDefaults

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
@Test
public void testChineseDefaults() throws Exception {
  SolrServer server = getSolrServer();
  // Empty the database...
  server.deleteByQuery( "*:*" );// delete everything!
  server.commit();
  assertNumFound( "*:*", 0 ); // make sure it got in

  // Beijing medical University
  UpdateRequest req = new UpdateRequest();
  SolrInputDocument doc = new SolrInputDocument();
  doc.addField("id", "42");
  doc.addField("text", "北京医科大学");
  req.add(doc);

  req.setAction(ACTION.COMMIT, true, true );
  req.process( server );

  // Beijing university should match:
  SolrQuery query = new SolrQuery("北京大学");
  QueryResponse rsp = server.query( query );
  assertEquals(1, rsp.getResults().getNumFound());
}
 
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:SolrExampleTests.java

示例8: index_specific

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
@Override
protected void index_specific(int serverNumber, Object... fields)
    throws Exception {
  SolrInputDocument doc = new SolrInputDocument();
  for (int i = 0; i < fields.length; i += 2) {
    doc.addField((String) (fields[i]), fields[i + 1]);
  }
  controlClient.add(doc);
  
  HttpSolrServer client = (HttpSolrServer) clients
      .get(serverNumber);
  
  UpdateRequest ureq = new UpdateRequest();
  ureq.add(doc);
  // ureq.setParam("update.chain", DISTRIB_UPDATE_CHAIN);
  ureq.process(client);
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:AbstractFullDistribZkTestBase.java

示例9: indexDocumentAndWaitForSync

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
private void indexDocumentAndWaitForSync(String docId) {
    final SolrInputDocument doc = new SolrInputDocument();
    doc.setField("id", docId);
    final UpdateRequest docUpdate = new UpdateRequest();
    docUpdate.add(doc);
    docUpdate.setParam(UpdateParams.COLLECTION, COLLECTION_NAME);
    docUpdate.setWaitSearcher(true);
    docUpdate.setParam(UpdateParams.SOFT_COMMIT, Boolean.TRUE.toString());
    try {
        final UpdateResponse response = docUpdate.process(solrClient);
        assertThat(response.getStatus()).isEqualTo(0);
        SolrCloudUtils.waitForReplicasToSync(COLLECTION_NAME, solrClient, WAIT_TIMEOUT_SECONDS);
    } catch (SolrServerException | IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:shaie,项目名称:lucenelab,代码行数:17,代码来源:MiniSolrCloudClusterTest.java

示例10: addBeans

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的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:pkarmstr,项目名称:NYBC,代码行数:33,代码来源:HttpSolrServer.java

示例11: indexDoc

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
@Override
protected void indexDoc(SolrInputDocument doc) throws IOException,
    SolrServerException {
  controlClient.add(doc);
  
  // if we wanted to randomly pick a client - but sometimes they may be
  // down...
  
  // boolean pick = random.nextBoolean();
  //
  // int which = (doc.getField(id).toString().hashCode() & 0x7fffffff) %
  // sliceCount;
  //
  // if (pick && sliceCount > 1) {
  // which = which + ((shardCount / sliceCount) *
  // random.nextInt(sliceCount-1));
  // }
  //
  // CommonsHttpSolrServer client = (CommonsHttpSolrServer)
  // clients.get(which);
  
  UpdateRequest ureq = new UpdateRequest();
  ureq.add(doc);
  // ureq.setParam(UpdateParams.UPDATE_CHAIN, DISTRIB_UPDATE_CHAIN);
  ureq.process(cloudClient);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:27,代码来源:AbstractFullDistribZkTestBase.java

示例12: index

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
@Override
public void index() throws IOException, SolrServerException {
    LOGGER.info("Sending {} to SOLR...", document.getFieldValue("id"));
    UpdateRequest updateRequest = getUpdateRequest(MCRSolrConstants.UPDATE_PATH);
    updateRequest.add(document);
    updateRequest.process(getSolrClient());
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:8,代码来源:MCRSolrInputDocumentHandler.java

示例13: index

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
@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.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());
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:34,代码来源:MCRSolrInputDocumentsHandler.java

示例14: deleteById

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
/**
 * Deletes a list of documents by unique ID. Also removes any nested document of that ID.
 *
 * @param solrIDs
 *            the list of solr document IDs to delete
 */
public static UpdateResponse deleteById(String... solrIDs) {
    if (solrIDs == null || solrIDs.length == 0) {
        return null;
    }
    SolrClient solrClient = MCRSolrClientFactory.getSolrClient();
    UpdateResponse updateResponse = null;
    long start = System.currentTimeMillis();
    try {
        LOGGER.debug("Deleting \"{}\" from solr", Arrays.asList(solrIDs));
        UpdateRequest req = new UpdateRequest();
        //delete all documents rooted at this id
        if (MCRSolrUtils.useNestedDocuments()) {
            StringBuilder deleteQuery = new StringBuilder("_root_:(");
            for (String solrID : solrIDs) {
                deleteQuery.append('"');
                deleteQuery.append(MCRSolrUtils.escapeSearchValue(solrID));
                deleteQuery.append("\" ");
            }
            deleteQuery.setCharAt(deleteQuery.length() - 1, ')');
            req.deleteByQuery(deleteQuery.toString());
        }
        //for document without nested
        req.deleteById(Arrays.asList(solrIDs));
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Delete request: {}", req.getXML());
        }
        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;

}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:45,代码来源:MCRSolrIndexer.java

示例15: deleteDerivate

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
/**
 * 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(String id) {
    if (id == null) {
        return null;
    }
    SolrClient solrClient = MCRSolrClientFactory.getSolrClient();
    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;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:35,代码来源:MCRSolrIndexer.java


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