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


Java HttpSolrServer.getHttpClient方法代码示例

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


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

示例1: testArbitraryJsonIndexing

import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@Test
public void testArbitraryJsonIndexing() throws Exception  {
  HttpSolrServer server = (HttpSolrServer) getSolrServer();
  server.deleteByQuery("*:*");
  server.commit();
  assertNumFound("*:*", 0); // make sure it got in

  // two docs, one with uniqueKey, another without it
  String json = "{\"id\":\"abc1\", \"name\": \"name1\"} {\"name\" : \"name2\"}";
  HttpClient httpClient = server.getHttpClient();
  HttpPost post = new HttpPost(server.getBaseURL() + "/update/json/docs");
  post.setHeader("Content-Type", "application/json");
  post.setEntity(new InputStreamEntity(new ByteArrayInputStream(json.getBytes("UTF-8")), -1));
  HttpResponse response = httpClient.execute(post);
  assertEquals(200, response.getStatusLine().getStatusCode());
  server.commit();
  assertNumFound("*:*", 2);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:SolrSchemalessExampleTests.java

示例2: testHttpResponse

import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@Test
public void testHttpResponse() throws SolrServerException, IOException {
  HttpSolrServer client = (HttpSolrServer)getSolrServer();
  HttpClient httpClient = client.getHttpClient();
  URI uri = URI.create(client.getBaseURL() + "/withHeaders?q=*:*");
  HttpGet httpGet = new HttpGet(uri);
  HttpResponse response = httpClient.execute(httpGet);
  Header[] headers = response.getAllHeaders();
  boolean containsWarningHeader = false;
  for (Header header:headers) {
    if ("Warning".equals(header.getName())) {
      containsWarningHeader = true;
      assertEquals("This is a test warning", header.getValue());
      break;
    }
  }
  assertTrue("Expected header not found", containsWarningHeader);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:ResponseHeaderTest.java

示例3: setAuthentication

import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
private static void setAuthentication(HttpSolrServer httpServer) {
	String user = SolrMeterConfiguration.getProperty("solr.server.configuration.httpAuthUser");
	String pass = SolrMeterConfiguration.getProperty("solr.server.configuration.httpAuthPass");
	if(user != null && !user.isEmpty() && pass != null && !pass.isEmpty()) {
		AbstractHttpClient client = (AbstractHttpClient) httpServer.getHttpClient();
		client.addRequestInterceptor(new PreEmptiveBasicAuthenticator(user, pass));
	}
}
 
开发者ID:lafourchette,项目名称:solrmeter,代码行数:9,代码来源:SolrServerRegistry.java

示例4: afterPropertiesSet

import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
    if (querySolrServer instanceof HttpSolrServer) {
        HttpSolrServer httpSolrServer = (HttpSolrServer) querySolrServer;
        this.updateSolrServer = new ConcurrentUpdateSolrServer(httpSolrServer.getBaseURL(), httpSolrServer.getHttpClient(), 20, 4);
    } else {
        this.updateSolrServer = querySolrServer;
    }
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:10,代码来源:DefaultSolrDao.java

示例5: getClient

import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
protected HttpClient getClient() {
  HttpSolrServer httpserver = (HttpSolrServer)getSolrServer();
  return httpserver.getHttpClient();
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:CacheHeaderTestBase.java


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