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


Java UpdateRequest.setCommitWithin方法代码示例

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


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

示例1: importRecord

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
private static void importRecord(String rec) throws SolrServerException, IOException, JSONException {

        // System.out.println(">>> Import a record ");

        // JSON record erzeugen ...
        JSONObject o = parseJSON(rec);

        SolrInputDocument document = new SolrInputDocument();

        Iterator k = o.keys();
        while (k.hasNext()) {
            String key = (String) k.next();
//                System.out.println( key + "  " + o.get(key).toString() );
            document.addField(key, o.get(key).toString());
        }

        
        UpdateRequest add = new UpdateRequest();
        add.add(document);
        add.setCommitWithin(30000);
        add.setParam("collection", collection);
        add.process(solr);
    }
 
开发者ID:kamir,项目名称:MorphMiner,代码行数:24,代码来源:ResultLineImporter.java

示例2: addOperation

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
UpdateRequest addOperation(boolean delete) {
  UpdateRequest result;
  if (delete) {
    result = (this.lastDelete = new UpdateRequest());
  } else {
    result = (this.lastUpdate = new UpdateRequest());
  }
  this.operations.add(result);
  this.lastOperationIsDelete = delete;
  if (this.config.commitWithin > 0) {
    result.setCommitWithin(this.config.commitWithin);
  }
  return result;
}
 
开发者ID:jcustenborder,项目名称:kafka-connect-solr,代码行数:15,代码来源:Operations.java

示例3: getUpdateRequest

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
protected UpdateRequest getUpdateRequest(String path) {
    UpdateRequest req = path != null ? new UpdateRequest(path) : new UpdateRequest();
    req.setCommitWithin(getCommitWithin());
    return req;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:6,代码来源:MCRSolrAbstractIndexHandler.java

示例4: testCommitWithinOnAdd

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
/**
 * query the example
 */
@Test
public void testCommitWithinOnAdd() throws Exception {
  // make sure it is empty...
  SolrServer server = getSolrServer();
  server.deleteByQuery("*:*");// delete everything!
  server.commit();
  QueryResponse rsp = server.query(new SolrQuery("*:*"));
  Assert.assertEquals(0, rsp.getResults().getNumFound());
  
  // Now try a timed commit...
  SolrInputDocument doc3 = new SolrInputDocument();
  doc3.addField("id", "id3", 1.0f);
  doc3.addField("name", "doc3", 1.0f);
  doc3.addField("price", 10);
  UpdateRequest up = new UpdateRequest();
  up.add(doc3);
  up.setCommitWithin(500); // a smaller commitWithin caused failures on the
                           // following assert
  up.process(server);
  
  rsp = server.query(new SolrQuery("*:*"));
  Assert.assertEquals(0, rsp.getResults().getNumFound());
  
  // TODO: not a great way to test this - timing is easily out
  // of whack due to parallel tests and various computer specs/load
  Thread.sleep(1000); // wait 1 sec
  
  // now check that it comes out...
  rsp = server.query(new SolrQuery("id:id3"));
  
  int cnt = 0;
  while (rsp.getResults().getNumFound() == 0) {
    // wait and try again for slower/busier machines
    // and/or parallel test effects.
    
    if (cnt++ == 10) {
      break;
    }
    
    Thread.sleep(2000); // wait 2 seconds...
    
    rsp = server.query(new SolrQuery("id:id3"));
  }
  
  Assert.assertEquals(1, rsp.getResults().getNumFound());
  
  // Now test the new convenience parameter on the add() for commitWithin
  SolrInputDocument doc4 = new SolrInputDocument();
  doc4.addField("id", "id4", 1.0f);
  doc4.addField("name", "doc4", 1.0f);
  doc4.addField("price", 10);
  server.add(doc4, 500);
  
  Thread.sleep(1000); // wait 1 sec
  
  // now check that it comes out...
  rsp = server.query(new SolrQuery("id:id4"));
  
  cnt = 0;
  while (rsp.getResults().getNumFound() == 0) {
    // wait and try again for slower/busier machines
    // and/or parallel test effects.
    
    if (cnt++ == 10) {
      break;
    }
    
    Thread.sleep(2000); // wait 2 seconds...
    
    rsp = server.query(new SolrQuery("id:id3"));
  }
  
  Assert.assertEquals(1, rsp.getResults().getNumFound());
}
 
开发者ID:europeana,项目名称:search,代码行数:78,代码来源:SolrExampleTestsBase.java

示例5: testCommitWithinOnDelete

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
@Test
public void testCommitWithinOnDelete() throws Exception {
  // make sure it is empty...
  SolrServer server = getSolrServer();
  server.deleteByQuery("*:*");// delete everything!
  server.commit();
  QueryResponse rsp = server.query(new SolrQuery("*:*"));
  Assert.assertEquals(0, rsp.getResults().getNumFound());
  
  // Now add one document...
  SolrInputDocument doc3 = new SolrInputDocument();
  doc3.addField("id", "id3", 1.0f);
  doc3.addField("name", "doc3", 1.0f);
  doc3.addField("price", 10);
  server.add(doc3);
  server.commit();
  
  // now check that it comes out...
  rsp = server.query(new SolrQuery("id:id3"));
  Assert.assertEquals(1, rsp.getResults().getNumFound());
  
  // now test commitWithin on a delete
  UpdateRequest up = new UpdateRequest();
  up.setCommitWithin(1000);
  up.deleteById("id3");
  up.process(server);
  
  // the document should still be there
  rsp = server.query(new SolrQuery("id:id3"));
  Assert.assertEquals(1, rsp.getResults().getNumFound());
  
  // check if the doc has been deleted every 250 ms for 30 seconds
  long timeout = System.currentTimeMillis() + 30000;
  do {
    Thread.sleep(250); // wait 250 ms
    
    rsp = server.query(new SolrQuery("id:id3"));
    if (rsp.getResults().getNumFound() == 0) {
      return;
    }
  } while (System.currentTimeMillis() < timeout);
  
  Assert.fail("commitWithin failed to commit");
}
 
开发者ID:europeana,项目名称:search,代码行数:45,代码来源:SolrExampleTestsBase.java

示例6: testCommitWithinOnAdd

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
/**
  * query the example
  */
@Test
public void testCommitWithinOnAdd() throws Exception
 {    
   // make sure it is empty...
   SolrServer server = getSolrServer();
   server.deleteByQuery( "*:*" );// delete everything!
   server.commit();
   QueryResponse rsp = server.query( new SolrQuery( "*:*") );
   Assert.assertEquals( 0, rsp.getResults().getNumFound() );

   // Now try a timed commit...
   SolrInputDocument doc3 = new SolrInputDocument();
   doc3.addField( "id", "id3", 1.0f );
   doc3.addField( "name", "doc3", 1.0f );
   doc3.addField( "price", 10 );
   UpdateRequest up = new UpdateRequest();
   up.add( doc3 );
   up.setCommitWithin( 500 );  // a smaller commitWithin caused failures on the following assert
   up.process( server );
   
   rsp = server.query( new SolrQuery( "*:*") );
   Assert.assertEquals( 0, rsp.getResults().getNumFound() );
   
   // TODO: not a great way to test this - timing is easily out
   // of whack due to parallel tests and various computer specs/load
   Thread.sleep( 1000 ); // wait 1 sec

   // now check that it comes out...
   rsp = server.query( new SolrQuery( "id:id3") );
   
   int cnt = 0;
   while (rsp.getResults().getNumFound() == 0) {
     // wait and try again for slower/busier machines
     // and/or parallel test effects.
     
     if (cnt++ == 10) {
       break;
     }
     
     Thread.sleep( 2000 ); // wait 2 seconds...
     
     rsp = server.query( new SolrQuery( "id:id3") );
   }
   
   Assert.assertEquals( 1, rsp.getResults().getNumFound() );
   
   // Now test the new convenience parameter on the add() for commitWithin
   SolrInputDocument doc4 = new SolrInputDocument();
   doc4.addField( "id", "id4", 1.0f );
   doc4.addField( "name", "doc4", 1.0f );
   doc4.addField( "price", 10 );
   server.add(doc4, 500);
   
   Thread.sleep( 1000 ); // wait 1 sec

   // now check that it comes out...
   rsp = server.query( new SolrQuery( "id:id4") );

   cnt = 0;
   while (rsp.getResults().getNumFound() == 0) {
     // wait and try again for slower/busier machines
     // and/or parallel test effects.
     
     if (cnt++ == 10) {
       break;
     }
     
     Thread.sleep( 2000 ); // wait 2 seconds...
     
     rsp = server.query( new SolrQuery( "id:id3") );
   }
   
   Assert.assertEquals( 1, rsp.getResults().getNumFound() );
 }
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:78,代码来源:SolrExampleTests.java

示例7: testCommitWithinOnDelete

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
@Test
public void testCommitWithinOnDelete() throws Exception
 {    
   // make sure it is empty...
   SolrServer server = getSolrServer();
   server.deleteByQuery( "*:*" );// delete everything!
   server.commit();
   QueryResponse rsp = server.query( new SolrQuery( "*:*") );
   Assert.assertEquals( 0, rsp.getResults().getNumFound() );

   // Now add one document...
   SolrInputDocument doc3 = new SolrInputDocument();
   doc3.addField( "id", "id3", 1.0f );
   doc3.addField( "name", "doc3", 1.0f );
   doc3.addField( "price", 10 );
   server.add(doc3);
   server.commit();

   // now check that it comes out...
   rsp = server.query( new SolrQuery( "id:id3") );    
   Assert.assertEquals( 1, rsp.getResults().getNumFound() );
   
   // now test commitWithin on a delete
   UpdateRequest up = new UpdateRequest();
   up.setCommitWithin(1000);
   up.deleteById("id3");
   up.process( server );
   
   // the document should still be there
   rsp = server.query( new SolrQuery( "id:id3") );
   Assert.assertEquals( 1, rsp.getResults().getNumFound() );
   
   // check if the doc has been deleted every 250 ms for 30 seconds
   long timeout = System.currentTimeMillis() + 30000;
   do {
     Thread.sleep( 250 ); // wait 250 ms
     
     rsp = server.query( new SolrQuery( "id:id3") );
     if(rsp.getResults().getNumFound()==0) {
       return;
     }
   } while(System.currentTimeMillis()<timeout);
   
   Assert.fail("commitWithin failed to commit");
 }
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:46,代码来源:SolrExampleTests.java

示例8: add

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
/**
 * Adds a collection of documents, specifying max time before they become committed
 * @param docs  the collection of documents
 * @param commitWithinMs  max time (in ms) before a commit will happen 
 * @throws IOException If there is a low-level I/O error.
 * @since solr 3.5
 */
public UpdateResponse add(Collection<SolrInputDocument> docs, int commitWithinMs) throws SolrServerException, IOException {
  UpdateRequest req = new UpdateRequest();
  req.add(docs);
  req.setCommitWithin(commitWithinMs);
  return req.process(this);
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:SolrServer.java

示例9: deleteById

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
/**
 * Deletes a single document by unique ID, specifying max time before commit
 * @param id  the ID of the document to delete
 * @param commitWithinMs  max time (in ms) before a commit will happen 
 * @throws IOException If there is a low-level I/O error.
 * @since 3.6
 */
public UpdateResponse deleteById(String id, int commitWithinMs) throws SolrServerException, IOException {
  UpdateRequest req = new UpdateRequest();
  req.deleteById(id);
  req.setCommitWithin(commitWithinMs);
  return req.process(this);
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:SolrServer.java

示例10: deleteByQuery

import org.apache.solr.client.solrj.request.UpdateRequest; //导入方法依赖的package包/类
/**
 * Deletes documents from the index based on a query, specifying max time before commit
 * @param query  the query expressing what documents to delete
 * @param commitWithinMs  max time (in ms) before a commit will happen 
 * @throws IOException If there is a low-level I/O error.
 * @since 3.6
 */
public UpdateResponse deleteByQuery(String query, int commitWithinMs) throws SolrServerException, IOException {
  UpdateRequest req = new UpdateRequest();
  req.deleteByQuery(query);
  req.setCommitWithin(commitWithinMs);
  return req.process(this);
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:SolrServer.java


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