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


Java SolrServer.commit方法代码示例

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


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

示例1: persistToSolr

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

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
/**
 * Manually purge the index to try again.
 * Since this cascade is currently ordered, can be used to purge before we load.
 * 
 * @param opts
 * @throws Exception
 */
@SuppressWarnings("deprecation")
@CLIMethod("--solr-purge")
public void purgeSolr(Opts opts) throws Exception  {

	// Check to see if the global url has been set.
	String url = sortOutSolrURL(globalSolrURL);				

	// Wipe out the solr index at url.
	SolrServer server = new CommonsHttpSolrServer(url);
	server.deleteByQuery("*:*");
	server.commit();

	// Probably worked, so let's destroy the log if there is one.
	if( globalSolrLogFile != null && globalSolrLogFile.exists() ){
	    boolean yes_p = globalSolrLogFile.delete();
	    if( yes_p ){
	        LOG.info("Deleted GOlr load log file.");
	    }else{
	        // Nothing there, doing nothing.
	    }
	}
	LOG.info("Purged: " + url);
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:31,代码来源:SolrCommandRunner.java

示例3: commit

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
@Override
public void commit(SolrServer server, boolean softCommit, boolean waitSearcher, boolean waitFlush) throws ServiceException, IOException {
    try {
        if (!this.commit) {
            LOG.warn("The flag / property \"solr.index.commit\" is set to false but a commit is being forced via the API.");
        }

        if (LOG.isDebugEnabled()) {
            LOG.debug("Committing changes to Solr index: softCommit: " + softCommit
                    + ", waitSearcher: " + waitSearcher + ", waitFlush: " + waitFlush);
        }

        server.commit(waitFlush, waitSearcher, softCommit);
    } catch (SolrServerException e) {
        throw new ServiceException("Could not commit changes to Solr index", e);
    }
}
 
开发者ID:takbani,项目名称:blcdemo,代码行数:18,代码来源:SolrIndexServiceImpl.java

示例4: createThumbnailForBook

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public static void createThumbnailForBook(String solrURL, String solrCore, String bookID) throws SolrServerException, IOException {
    SolrServer server = SolrHandler.createConnection(solrURL, solrCore);
    QueryResponse response = SolrHandler.searchSolrIndex(server, "id:"+bookID, 1, 0);
    List<BookEntry> bookEntries = response.getBeans(BookEntry.class);
    System.out.println("Retrieved " + (bookEntries.size()) + " of " + response.getResults().getNumFound());
    for(BookEntry bookEntry : bookEntries) {
        if (bookEntry.getCover() != null) {
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            Thumbnails.of(new ByteArrayInputStream(bookEntry.getCover()))
                                .size(130, 200)
                                .toOutputStream(output);

            SolrInputDocument doc = new SolrInputDocument();
            doc.addField("id", bookEntry.getId());
            
            Map<String, Object> thumbnailData = new HashMap<>();
            thumbnailData.put("set", output.toByteArray());
            doc.addField("thumbnail", thumbnailData);
            
            Map<String, Object> thumbnailStatus = new HashMap<>();
            thumbnailStatus.put("set", "done");
            doc.addField("thumbnailgenerated", thumbnailStatus);
            
            server.add(doc);
            server.commit();    
        }
         
    }
}
 
开发者ID:felixhusse,项目名称:bookery,代码行数:30,代码来源:ThumbnailConvert.java

示例5: convertBatchWise

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
private static void convertBatchWise(SolrServer server,int batchSize, int offset) throws SolrServerException, IOException {
    QueryResponse response = SolrHandler.searchSolrIndex(server, "-thumbnailgenerated:done", batchSize, offset);
    List<BookEntry> bookEntries = response.getBeans(BookEntry.class);
    System.out.println("Retrieved " + (bookEntries.size() + offset) + " of " + response.getResults().getNumFound());
    for(BookEntry bookEntry : bookEntries) {
        if (bookEntry.getCover() != null) {
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            Thumbnails.of(new ByteArrayInputStream(bookEntry.getCover()))
                                .size(130, 200)
                                .toOutputStream(output);

            SolrInputDocument doc = new SolrInputDocument();
            doc.addField("id", bookEntry.getId());
            
            Map<String, Object> thumbnailData = new HashMap<>();
            thumbnailData.put("set", output.toByteArray());
            doc.addField("thumbnail", thumbnailData);
            
            Map<String, Object> thumbnailStatus = new HashMap<>();
            thumbnailStatus.put("set", "done");
            doc.addField("thumbnailgenerated", thumbnailStatus);
            
            server.add(doc);
            server.commit();     
        }
         
    }
    response = SolrHandler.searchSolrIndex(server, "-thumbnailgenerated:done", batchSize, offset);
    if(response.getResults().getNumFound() > 0) {
        convertBatchWise(server, batchSize, 0);
    }
}
 
开发者ID:felixhusse,项目名称:bookery,代码行数:33,代码来源:ThumbnailConvert.java

示例6: doBefore

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
@Before
public void doBefore() throws IOException, SolrServerException {
  //add document and commit, and ensure it's there
  SolrServer server1 = getSolrServer();
  SolrInputDocument doc = new SolrInputDocument();
  doc.addField("id", "1234");
  server1.add(doc);
  server1.commit();
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:NoOpResponseParserTest.java

示例7: doBefore

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
@Before
public void doBefore() throws IOException, SolrServerException {
  //add document and commit, and ensure it's there
  SolrServer server1 = getSolrServer();
  SolrInputDocument doc = new SolrInputDocument();
  doc.addField( "id", "1234" );
  server1.add(doc);
  server1.commit();
  assertTrue(searchFindsIt());
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:TestRemoteStreaming.java

示例8: testUpdateByCollectionName

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
private void testUpdateByCollectionName() throws SolrServerException, IOException {
  log.info("### STARTING testUpdateByCollectionName");
  SolrServer client = clients.get(0);
  final String baseUrl = ((HttpSolrServer) client).getBaseURL().substring(
      0,
      ((HttpSolrServer) client).getBaseURL().length()
          - DEFAULT_COLLECTION.length() - 1);
  
  // the cores each have different names, but if we add the collection name to the url
  // we should get mapped to the right core
  // test hitting an update url
  SolrServer client1 = createNewSolrServer(oneInstanceCollection, baseUrl);
  client1.commit();
  client1.shutdown();
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:BasicDistributedZkTest.java

示例9: test

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
@Test
public void test() throws SolrServerException, IOException {
    TestAgentController.installIfRequired("./target/test-events.json");

    assertEquals(0, TestAgentController.getCollectedEventCount());

    SolrServerFactory solrServerFactory = new SolrServerFactory();
    solrServerFactory.setUrl("file:./target/solr");
    solrServerFactory.setEmbeddedSolrConfigurationDir("./src/test/resources/solr");
    solrServerFactory.initialize();

    SolrServer solrServer = solrServerFactory.getObject();

    assertEquals(0, TestAgentController.getCollectedEventCount());

    SolrInputDocument solrInputDocument = new SolrInputDocument();
    solrInputDocument.setField("id", UUID.randomUUID().toString());
    solrInputDocument.setField("timestamp", new Date());
    solrServer.add(solrInputDocument);

    assertEquals(0, TestAgentController.getCollectedEventCount());

    solrServer.commit(true, true);

    List<Event> collectedEvents = TestAgentController.getCollectedEvents();
    assertEquals(2, collectedEvents.size());
    Event event = collectedEvents.get(0);
    assertEquals("Embedded Core", getProperty(event.getStringProperties(), "core_name"));
    assertEquals("solr/core/commit", event.getType());

    event = collectedEvents.get(1);
    assertEquals("Embedded Core", getProperty(event.getStringProperties(), "core_name"));
    assertEquals("solr/core/new-searcher", event.getType());

    solrServerFactory.destroy();
    AgentControllerProvider.shutdown();
}
 
开发者ID:Indoqa,项目名称:logspace,代码行数:38,代码来源:SolrAgentTest.java

示例10: deleteAllDocuments

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
private void deleteAllDocuments() throws SolrServerException, IOException {
  SolrServer s = solrServer;
  s.deleteByQuery("*:*"); // delete everything!
  s.commit();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:6,代码来源:TestMorphlineSolrSink.java

示例11: addBeans

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public static UpdateResponse addBeans(SolrServer solr, List<BookEntry> bookEntries) throws SolrServerException, IOException {
    solr.addBeans(bookEntries);
    return solr.commit();
}
 
开发者ID:felixhusse,项目名称:bookery,代码行数:5,代码来源:SolrHandler.java

示例12: resetSolrIndex

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public static void resetSolrIndex(SolrServer solr) throws SolrServerException, IOException {
    solr.deleteByQuery("*:*");
    solr.commit();
}
 
开发者ID:felixhusse,项目名称:bookery,代码行数:5,代码来源:SolrHandler.java

示例13: clearDB

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public static void clearDB(String solrURL, String solrCore) throws SolrServerException, IOException {
    SolrServer server = SolrHandler.createConnection(solrURL, solrCore);
    System.out.println("RESET:");
    server.deleteByQuery("*:*");
    server.commit();
}
 
开发者ID:felixhusse,项目名称:bookery,代码行数:7,代码来源:BookMigrator.java

示例14: addBeans

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public void addBeans(List<BookEntry> bookEntries) throws SolrServerException, IOException {
    SolrServer solr = bookeryService.getSolrConnection();
    solr.addBeans(bookEntries);
    UpdateResponse response = solr.commit(true, false);
}
 
开发者ID:felixhusse,项目名称:bookery,代码行数:6,代码来源:SolrHandler.java

示例15: updateBean

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
public void updateBean(BookEntry bookEntry) throws SolrServerException, IOException {
    SolrServer solr = bookeryService.getSolrConnection();
    solr.addBean(bookEntry);
    solr.commit();
    
}
 
开发者ID:felixhusse,项目名称:bookery,代码行数:7,代码来源:SolrHandler.java


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