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


Java SolrClient.commit方法代码示例

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


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

示例1: testRuntimeLib

import org.apache.solr.client.solrj.SolrClient; //导入方法依赖的package包/类
@Test
public void testRuntimeLib() throws SolrServerException, IOException {
    SearchServer server = testSearchServer.getSearchServer();

    SolrClient client = (SolrClient) server.getBackend();

    SolrInputDocument document = new SolrInputDocument();
    document.setField("_id_", "1");
    document.setField("_type_", "doc");
    document.setField("dynamic_multi_facet_string_f1", "test");
    document.setField("dynamic_multi_facet_string_f2", "hello");

    client.add(document);
    client.commit();

    SolrQuery query = new SolrQuery("t");
    query.setRequestHandler("/suggester");
    query.set("suggestion.df", "facets");
    query.set("suggestion.field", "dynamic_multi_facet_string_f1");

    QueryResponse response = client.query(query);

    assertEquals(1, ((HashMap) response.getResponse().get("suggestions")).get("suggestion_count"));
}
 
开发者ID:RBMHTechnology,项目名称:vind,代码行数:25,代码来源:TestServerTest.java

示例2: updateDocs

import org.apache.solr.client.solrj.SolrClient; //导入方法依赖的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

示例3: shutdownGracefully

import org.apache.solr.client.solrj.SolrClient; //导入方法依赖的package包/类
private void shutdownGracefully(SolrClient client) throws SolrServerException, IOException {
    if (client != null) {
        LOGGER.info("Shutting down solr client: {}", client);
        client.commit(false, false);
        client.close();
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:8,代码来源:MCRSolrCore.java

示例4: deleteById

import org.apache.solr.client.solrj.SolrClient; //导入方法依赖的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

示例5: deleteDerivate

import org.apache.solr.client.solrj.SolrClient; //导入方法依赖的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

示例6: commit

import org.apache.solr.client.solrj.SolrClient; //导入方法依赖的package包/类
@Override
public void commit() throws IOException {
  push();
  try {
    for (SolrClient solrClient : solrClients) {
      solrClient.commit();
    }
  } catch (final SolrServerException e) {
    LOG.error("Failed to commit solr connection: " + e.getMessage()); // FIXME
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:12,代码来源:SolrIndexWriter.java

示例7: setUp

import org.apache.solr.client.solrj.SolrClient; //导入方法依赖的package包/类
/**
 * Indexes some sample data as test fixture.
 * 
 * @throws Exception hopefully never, otherwise the test will fail.
 */
@Before
public void setUp() throws Exception {
	super.setUp();
	final SolrClient indexer = getSolrClient();
	final SolrInputDocument book1 = new SolrInputDocument();
	book1.setField("id","1");
	book1.setField("title","Apache Solr Essentials");
	book1.setField("author","Andrea Gazzarini");
	
	indexer.add(book1);
	indexer.commit();
}
 
开发者ID:spaziocodice,项目名称:invisible-queries-request-handler,代码行数:18,代码来源:FacadeRequestHandler_IT.java

示例8: tearDown

import org.apache.solr.client.solrj.SolrClient; //导入方法依赖的package包/类
@After 
public void tearDown() throws Exception {
	super.tearDown();
	final SolrClient indexer = getSolrClient();
	indexer.deleteByQuery("*:*");
	indexer.commit();
}
 
开发者ID:spaziocodice,项目名称:invisible-queries-request-handler,代码行数:8,代码来源:FacadeRequestHandler_IT.java

示例9: process

import org.apache.solr.client.solrj.SolrClient; //导入方法依赖的package包/类
@Override
public void process(Exchange exchange) throws Exception {

    String operation = (String) exchange.getIn().getHeader(SolrConstants.OPERATION);

    if (operation == null) {
        throw new IllegalArgumentException(SolrConstants.OPERATION + " header is missing");
    }

    SolrClient serverToUse = getBestSolrServer(operation);

    if (operation.equalsIgnoreCase(SolrConstants.OPERATION_INSERT)) {
        insert(exchange, serverToUse);
    } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_INSERT_STREAMING)) {
        insert(exchange, serverToUse);
    } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_DELETE_BY_ID)) {
        serverToUse.deleteById(exchange.getIn().getBody(String.class));
    } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_DELETE_BY_QUERY)) {
        serverToUse.deleteByQuery(exchange.getIn().getBody(String.class));
    } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_ADD_BEAN)) {
        serverToUse.addBean(exchange.getIn().getBody());
    } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_ADD_BEANS)) {
        serverToUse.addBeans(exchange.getIn().getBody(Collection.class));
    } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_COMMIT)) {
        serverToUse.commit();
    } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_ROLLBACK)) {
        serverToUse.rollback();
    } else if (operation.equalsIgnoreCase(SolrConstants.OPERATION_OPTIMIZE)) {
        serverToUse.optimize();
    } else {
        throw new IllegalArgumentException(
                SolrConstants.OPERATION + " header value '" + operation + "' is not supported");
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:35,代码来源:SolrProducer.java


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