當前位置: 首頁>>代碼示例>>Java>>正文


Java SolrCore.getUpdateHandler方法代碼示例

本文整理匯總了Java中org.apache.solr.core.SolrCore.getUpdateHandler方法的典型用法代碼示例。如果您正苦於以下問題:Java SolrCore.getUpdateHandler方法的具體用法?Java SolrCore.getUpdateHandler怎麽用?Java SolrCore.getUpdateHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.solr.core.SolrCore的用法示例。


在下文中一共展示了SolrCore.getUpdateHandler方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: PeerSync

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
public PeerSync(SolrCore core, List<String> replicas, int nUpdates, boolean cantReachIsSuccess, boolean getNoVersionsIsSuccess, boolean onlyIfActive) {
  this.replicas = replicas;
  this.nUpdates = nUpdates;
  this.maxUpdates = nUpdates;
  this.cantReachIsSuccess = cantReachIsSuccess;
  this.getNoVersionsIsSuccess = getNoVersionsIsSuccess;
  this.client = core.getCoreDescriptor().getCoreContainer().getUpdateShardHandler().getHttpClient();
  this.onlyIfActive = onlyIfActive;
  
  uhandler = core.getUpdateHandler();
  ulog = uhandler.getUpdateLog();
  // TODO: shutdown
  shardHandlerFactory = (HttpShardHandlerFactory) core.getCoreDescriptor().getCoreContainer().getShardHandlerFactory();
  shardHandler = shardHandlerFactory.getShardHandler(client);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:16,代碼來源:PeerSync.java

示例2: createMonitor

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
@Before
public void createMonitor() throws Exception {
  assumeFalse("This test is not working on Windows (or maybe machines with only 2 CPUs)",
    Constants.WINDOWS);

  SolrCore core = h.getCore();

  updater = (DirectUpdateHandler2) core.getUpdateHandler();
  monitor = new MockEventListener();

  core.registerNewSearcherListener(monitor);
  updater.registerSoftCommitCallback(monitor);
  updater.registerCommitCallback(monitor);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:15,代碼來源:SoftAutoCommitTest.java

示例3: testOptimize

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
public void testOptimize() throws Exception {
  SolrCore core = h.getCore();

  UpdateHandler updater = core.getUpdateHandler();
  SolrQueryRequest req = req();
  AddUpdateCommand cmd = new AddUpdateCommand(req);

  //add just under the merge factor, so no segments are merged
  //the merge factor is 100 and the maxBufferedDocs is 2, so there should be 50 segments
  for (int i = 0; i < 99; i++) {
    // Add a valid document
    cmd.solrDoc = new SolrInputDocument();
    cmd.solrDoc.addField("id", "id_" + i);
    cmd.solrDoc.addField("subject", "subject_" + i);
    updater.addDoc(cmd);
  }

  CommitUpdateCommand cmtCmd = new CommitUpdateCommand(req, false);
  updater.commit(cmtCmd);
  updater.commit(cmtCmd);  // commit twice to give systems such as windows a chance to delete the old files

  String indexDir = core.getIndexDir();
  assertNumSegments(indexDir, 50);

  //now do an optimize
  cmtCmd = new CommitUpdateCommand(req, true);
  cmtCmd.maxOptimizeSegments = 25;
  updater.commit(cmtCmd);
  updater.commit(cmtCmd);
  assertNumSegments(indexDir, 25);

  cmtCmd.maxOptimizeSegments = -1;
  try {
    updater.commit(cmtCmd);
    assertTrue(false);
  } catch (IllegalArgumentException e) {
  }
  cmtCmd.maxOptimizeSegments = 1;
  updater.commit(cmtCmd);
  updater.commit(cmtCmd);
  assertNumSegments(indexDir, 1);

  req.close();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:45,代碼來源:DirectUpdateHandlerOptimizeTest.java

示例4: testCommitWithin

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
public void testCommitWithin() throws Exception {
  SolrCore core = h.getCore();
  
  NewSearcherListener trigger = new NewSearcherListener();    
  core.registerNewSearcherListener(trigger);
  DirectUpdateHandler2 updater = (DirectUpdateHandler2) core.getUpdateHandler();
  CommitTracker tracker = updater.commitTracker;
  tracker.setTimeUpperBound(0);
  tracker.setDocsUpperBound(-1);
  
  UpdateRequestHandler handler = new UpdateRequestHandler();
  handler.init( null );
  
  MapSolrParams params = new MapSolrParams( new HashMap<String, String>() );
  
  // Add a single document with commitWithin == 2 second
  SolrQueryResponse rsp = new SolrQueryResponse();
  SolrQueryRequestBase req = new SolrQueryRequestBase( core, params ) {};
  req.setContentStreams( AutoCommitTest.toContentStreams(
    adoc(2000, "id", "529", "field_t", "what's inside?", "subject", "info"), null ) );
  trigger.reset();
  handler.handleRequest( req, rsp );

  // Check it isn't in the index
  assertQ("shouldn't find any", req("id:529") ,"//result[@numFound=0]" );
  
  // Wait longer than the commitWithin time
  assertTrue("commitWithin failed to commit", trigger.waitForNewSearcher(30000));

  // Add one document without commitWithin
  req.setContentStreams( AutoCommitTest.toContentStreams(
      adoc("id", "530", "field_t", "what's inside?", "subject", "info"), null ) );
    trigger.reset();
    handler.handleRequest( req, rsp );
    
  // Check it isn't in the index
  assertQ("shouldn't find any", req("id:530") ,"//result[@numFound=0]" );
  
  // Delete one document with commitWithin
  req.setContentStreams( AutoCommitTest.toContentStreams(
    delI("529", "commitWithin", "1000"), null ) );
  trigger.reset();
  handler.handleRequest( req, rsp );
    
  // Now make sure we can find it
  assertQ("should find one", req("id:529") ,"//result[@numFound=1]" );
  
  // Wait for the commit to happen
  assertTrue("commitWithin failed to commit", trigger.waitForNewSearcher(30000));
  
  // Now we shouldn't find it
  assertQ("should find none", req("id:529") ,"//result[@numFound=0]" );
  // ... but we should find the new one
  assertQ("should find one", req("id:530") ,"//result[@numFound=1]" );
  
  trigger.reset();
  
  // now make the call 10 times really fast and make sure it 
  // only commits once
  req.setContentStreams( AutoCommitTest.toContentStreams(
      adoc(2000, "id", "500" ), null ) );
  for( int i=0;i<10; i++ ) {
    handler.handleRequest( req, rsp );
  }
  assertQ("should not be there yet", req("id:500") ,"//result[@numFound=0]" );
  
  // the same for the delete
  req.setContentStreams( AutoCommitTest.toContentStreams(
      delI("530", "commitWithin", "1000"), null ) );
  for( int i=0;i<10; i++ ) {
    handler.handleRequest( req, rsp );
  }
  assertQ("should be there", req("id:530") ,"//result[@numFound=1]" );
  
  assertTrue("commitWithin failed to commit", trigger.waitForNewSearcher(30000));
  assertQ("should be there", req("id:500") ,"//result[@numFound=1]" );
  assertQ("should not be there", req("id:530") ,"//result[@numFound=0]" );
  
  assertEquals(3, tracker.getCommitCount());
}
 
開發者ID:europeana,項目名稱:search,代碼行數:81,代碼來源:HardAutoCommitTest.java

示例5: testMaxDocs

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
public void testMaxDocs() throws Exception {
  SolrCore core = h.getCore();
  
  NewSearcherListener trigger = new NewSearcherListener();

  DirectUpdateHandler2 updateHandler = (DirectUpdateHandler2)core.getUpdateHandler();
  CommitTracker tracker = updateHandler.softCommitTracker;
  tracker.setTimeUpperBound(-1);
  tracker.setDocsUpperBound(14);
  core.registerNewSearcherListener(trigger);

  
  UpdateRequestHandler handler = new UpdateRequestHandler();
  handler.init( null );
  
  MapSolrParams params = new MapSolrParams( new HashMap<String, String>() );
  
  // Add documents
  SolrQueryResponse rsp = new SolrQueryResponse();
  SolrQueryRequestBase req = new SolrQueryRequestBase( core, params ) {};
  for( int i=0; i<14; i++ ) {
    req.setContentStreams( toContentStreams(
      adoc("id", Integer.toString(i), "subject", "info" ), null ) );
    handler.handleRequest( req, rsp );
  }
  // It should not be there right away
  assertQ("shouldn't find any", req("id:1") ,"//result[@numFound=0]" );
  assertEquals( 0, tracker.getCommitCount());

  req.setContentStreams( toContentStreams(
      adoc("id", "14", "subject", "info" ), null ) );
  handler.handleRequest( req, rsp );

  assertTrue(trigger.waitForNewSearcher(15000));

  req.setContentStreams( toContentStreams(
      adoc("id", "15", "subject", "info" ), null ) );
  handler.handleRequest( req, rsp );
    
  // Now make sure we can find it
  assertQ("should find one", req("id:14") ,"//result[@numFound=1]" );
  assertEquals( 1, tracker.getCommitCount());
  // But not the one added afterward
  assertQ("should not find one", req("id:15") ,"//result[@numFound=0]" );
  assertEquals( 1, tracker.getCommitCount());
  
}
 
開發者ID:europeana,項目名稱:search,代碼行數:48,代碼來源:AutoCommitTest.java

示例6: testMaxTime

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
public void testMaxTime() throws Exception {
  SolrCore core = h.getCore();
  
  NewSearcherListener trigger = new NewSearcherListener();    
  core.registerNewSearcherListener(trigger);
  DirectUpdateHandler2 updater = (DirectUpdateHandler2) core.getUpdateHandler();
  CommitTracker tracker = updater.softCommitTracker;
  // too low of a number can cause a slow host to commit before the test code checks that it
  // isn't there... causing a failure at "shouldn't find any"
  tracker.setTimeUpperBound(1000);
  tracker.setDocsUpperBound(-1);
  // updater.commitCallbacks.add(trigger);
  
  UpdateRequestHandler handler = new UpdateRequestHandler();
  handler.init( null );
  
  MapSolrParams params = new MapSolrParams( new HashMap<String, String>() );
  
  // Add a single document
  SolrQueryResponse rsp = new SolrQueryResponse();
  SolrQueryRequestBase req = new SolrQueryRequestBase( core, params ) {};
  req.setContentStreams( toContentStreams(
    adoc("id", "529", "field_t", "what's inside?", "subject", "info"), null ) );
  trigger.reset();
  handler.handleRequest( req, rsp );

  // Check it it is in the index
  assertQ("shouldn't find any", req("id:529") ,"//result[@numFound=0]" );

  // Wait longer than the autocommit time
  assertTrue(trigger.waitForNewSearcher(45000));
  trigger.reset();
  req.setContentStreams( toContentStreams(
    adoc("id", "530", "field_t", "what's inside?", "subject", "info"), null ) );
  handler.handleRequest( req, rsp );
    
  // Now make sure we can find it
  assertQ("should find one", req("id:529") ,"//result[@numFound=1]" );
  // But not this one
  assertQ("should find none", req("id:530") ,"//result[@numFound=0]" );
  
  // Delete the document
  assertU( delI("529") );
  assertQ("deleted, but should still be there", req("id:529") ,"//result[@numFound=1]" );
  // Wait longer than the autocommit time
  assertTrue(trigger.waitForNewSearcher(30000));
  trigger.reset();
  req.setContentStreams( toContentStreams(
    adoc("id", "550", "field_t", "what's inside?", "subject", "info"), null ) );
  handler.handleRequest( req, rsp );
  assertEquals( 2, tracker.getCommitCount() );
  assertQ("deleted and time has passed", req("id:529") ,"//result[@numFound=0]" );
  
  // now make the call 10 times really fast and make sure it 
  // only commits once
  req.setContentStreams( toContentStreams(
      adoc("id", "500" ), null ) );
  for( int i=0;i<10; i++ ) {
    handler.handleRequest( req, rsp );
  }
  assertQ("should not be there yet", req("id:500") ,"//result[@numFound=0]" );
  
  // Wait longer than the autocommit time
  assertTrue(trigger.waitForNewSearcher(45000));
  trigger.reset();
  
  req.setContentStreams( toContentStreams(
    adoc("id", "531", "field_t", "what's inside?", "subject", "info"), null ) );
  handler.handleRequest( req, rsp );
  assertEquals( 3, tracker.getCommitCount() );

  assertQ("now it should", req("id:500") ,"//result[@numFound=1]" );
}
 
開發者ID:europeana,項目名稱:search,代碼行數:74,代碼來源:AutoCommitTest.java

示例7: testCommitWithin

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
public void testCommitWithin() throws Exception {
  SolrCore core = h.getCore();
  
  NewSearcherListener trigger = new NewSearcherListener();    
  core.registerNewSearcherListener(trigger);
  DirectUpdateHandler2 updater = (DirectUpdateHandler2) core.getUpdateHandler();
  CommitTracker tracker = updater.softCommitTracker;
  tracker.setTimeUpperBound(0);
  tracker.setDocsUpperBound(-1);
  
  UpdateRequestHandler handler = new UpdateRequestHandler();
  handler.init( null );
  
  MapSolrParams params = new MapSolrParams( new HashMap<String, String>() );
  
  // Add a single document with commitWithin == 4 second
  SolrQueryResponse rsp = new SolrQueryResponse();
  SolrQueryRequestBase req = new SolrQueryRequestBase( core, params ) {};
  req.setContentStreams( toContentStreams(
    adoc(4000, "id", "529", "field_t", "what's inside?", "subject", "info"), null ) );
  trigger.reset();
  handler.handleRequest( req, rsp );

  // Check it isn't in the index
  assertQ("shouldn't find any", req("id:529") ,"//result[@numFound=0]" );
  
  // Wait longer than the commitWithin time
  assertTrue("commitWithin failed to commit", trigger.waitForNewSearcher(30000));

  // Add one document without commitWithin
  req.setContentStreams( toContentStreams(
      adoc("id", "530", "field_t", "what's inside?", "subject", "info"), null ) );
    trigger.reset();
    handler.handleRequest( req, rsp );
    
  // Check it isn't in the index
  assertQ("shouldn't find any", req("id:530") ,"//result[@numFound=0]" );
  
  // Delete one document with commitWithin
  req.setContentStreams( toContentStreams(
    delI("529", "commitWithin", "1000"), null ) );
  trigger.reset();
  handler.handleRequest( req, rsp );
    
  // Now make sure we can find it
  assertQ("should find one", req("id:529") ,"//result[@numFound=1]" );
  
  // Wait for the commit to happen
  assertTrue("commitWithin failed to commit", trigger.waitForNewSearcher(30000));
  
  // Now we shouldn't find it
  assertQ("should find none", req("id:529") ,"//result[@numFound=0]" );
  // ... but we should find the new one
  assertQ("should find one", req("id:530") ,"//result[@numFound=1]" );
  
  trigger.reset();
  
  // now make the call 10 times really fast and make sure it 
  // only commits once
  req.setContentStreams( toContentStreams(
      adoc(2000, "id", "500" ), null ) );
  for( int i=0;i<10; i++ ) {
    handler.handleRequest( req, rsp );
  }
  assertQ("should not be there yet", req("id:500") ,"//result[@numFound=0]" );
  
  // the same for the delete
  req.setContentStreams( toContentStreams(
      delI("530", "commitWithin", "1000"), null ) );
  for( int i=0;i<10; i++ ) {
    handler.handleRequest( req, rsp );
  }
  assertQ("should be there", req("id:530") ,"//result[@numFound=1]" );
  
  assertTrue("commitWithin failed to commit", trigger.waitForNewSearcher(30000));
  assertQ("should be there", req("id:500") ,"//result[@numFound=1]" );
  assertQ("should not be there", req("id:530") ,"//result[@numFound=0]" );
  
  assertEquals(3, tracker.getCommitCount());
}
 
開發者ID:europeana,項目名稱:search,代碼行數:81,代碼來源:AutoCommitTest.java

示例8: addDoc

import org.apache.solr.core.SolrCore; //導入方法依賴的package包/類
private void addDoc(SolrCore core, String... fieldValues) throws IOException {
  UpdateHandler updater = core.getUpdateHandler();
  AddUpdateCommand cmd = new AddUpdateCommand(new LocalSolrQueryRequest(core, new NamedList<>()));
  cmd.solrDoc = sdoc((Object[]) fieldValues);
  updater.addDoc(cmd);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:7,代碼來源:ChangedSchemaMergeTest.java


注:本文中的org.apache.solr.core.SolrCore.getUpdateHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。