本文整理汇总了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() );
}
示例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"));
}
示例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() );
}
示例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);
}