當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。