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


Java ContentStreamUpdateRequest.addFile方法代码示例

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


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

示例1: testContentStreamRequest

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

   ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");
   up.addFile(getFile("solrj/books.csv"), "application/csv");
   up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
   NamedList<Object> result = server.request(up);
   assertNotNull("Couldn't upload books.csv", result);
   rsp = server.query( new SolrQuery( "*:*") );
   Assert.assertEquals( 10, rsp.getResults().getNumFound() );
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:SolrExampleTests.java

示例2: testCollectPing

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
@Test
public void testCollectPing() throws Exception {
    String configFile = "conf/config.yml";

    CloudSolrClient cloudSolrClient = cluster.getSolrClient();
    SolrCollectorConfig collectorConfig = new Yaml().loadAs(new FileReader(configFile), SolrCollectorConfig.class);

    SolrCollector collector = new SolrCollector(cloudSolrClient, collectorConfig, 1);
    collector.register(registry);

    // index sample docs
    File exampleDocsDir = new File("src/test/files/solr/example/exampledocs");
    List<File> xmlFiles = Arrays.asList(exampleDocsDir.listFiles((dir, name) -> name.endsWith(".xml")));
    for (File xml : xmlFiles) {
        ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update");
        req.addFile(xml, "application/xml");
        cloudSolrClient.request(req, "collection1");
    }
    cloudSolrClient.commit("collection1");

    collector.collect();

    assertNotEquals(0.0, registry.getSampleValue("solr_scrape_duration_seconds"));

}
 
开发者ID:mosuka,项目名称:solr-exporter,代码行数:26,代码来源:SolrCollectorTest.java

示例3: testMultiContentStreamRequest

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

   ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");
   up.addFile(getFile("solrj/docs1.xml"),"application/xml"); // 2
   up.addFile(getFile("solrj/docs2.xml"),"application/xml"); // 3
   up.setParam("a", "\u1234");
   up.setParam(CommonParams.HEADER_ECHO_PARAMS, CommonParams.EchoParamStyle.ALL.toString());
   up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
   NamedList<Object> result = server.request(up);
   Assert.assertEquals("\u1234",
       ((NamedList)((NamedList) result.get("responseHeader")).get("params")).get("a"));
   assertNotNull("Couldn't upload xml files", result);
   rsp = server.query( new SolrQuery( "*:*") );
   Assert.assertEquals( 5 , rsp.getResults().getNumFound() );
 }
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:SolrExampleTests.java

示例4: testNumberOfCommitsWithCommitAfterAdd

import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; //导入方法依赖的package包/类
private void testNumberOfCommitsWithCommitAfterAdd()
    throws SolrServerException, IOException {
  log.info("### STARTING testNumberOfCommitsWithCommitAfterAdd");
  long startCommits = getNumCommits((HttpSolrServer) clients.get(0));
  
  ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/update");
  up.addFile(getFile("books_numeric_ids.csv"), "application/csv");
  up.setCommitWithin(900000);
  up.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
  NamedList<Object> result = clients.get(0).request(up);
  
  long endCommits = getNumCommits((HttpSolrServer) clients.get(0));

  assertEquals(startCommits + 1L, endCommits);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:16,代码来源:BasicDistributedZkTest.java


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