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


Java HttpSolrServer.setBaseURL方法代码示例

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


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

示例1: checkResults

import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
private void checkResults(HttpSolrServer server, Queries queries, Indexer idxer) throws InterruptedException {
  log.info("Checking if indexes have all the documents they should...");
  long totalDocsFound = 0;
  for (Map.Entry<String, Long> ent : coreCounts.entrySet()) {
    server.setBaseURL(url + ent.getKey());
    for (int idx = 0; idx < 3; ++idx) {
      try {
        server.commit(true, true);
        break; // retry loop
      } catch (Exception e) {
        log.warn("Exception when committing core " + ent.getKey() + " " + e.getMessage());
        Thread.sleep(100L);
      }
    }
    long numFound = queries.getCount(server, ent.getKey());
    totalDocsFound += numFound;
    assertEquals(String.format(Locale.ROOT, "Core %s bad!", ent.getKey()), (long) ent.getValue(), numFound);
  }

  log.info(String.format(Locale.ROOT, "\n\nDocs indexed (cumulative, all cycles): %,d, total docs: %,d: Cycle stats: updates: %,d: qtimes: %,d",
      Indexer.idUnique.get(), totalDocsFound, idxer.getAccumUpdates(), idxer.getAccumQtimes()));

  cumulativeDocs += totalDocsFound;
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:OpenCloseCoreStressTest.java

示例2: doTest

import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
@Override
public void doTest() throws Exception {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.STATUS.toString());
  QueryRequest request = new QueryRequest(params);
  request.setPath("/admin/cores");
  int which = r.nextInt(clients.size());
  HttpSolrServer client = (HttpSolrServer)clients.get(which);
  String previousBaseURL = client.getBaseURL();
  // Strip /collection1 step from baseURL - requests fail otherwise
  client.setBaseURL(previousBaseURL.substring(0, previousBaseURL.lastIndexOf("/")));
  NamedList namedListResponse = client.request(request);
  client.setBaseURL(previousBaseURL); // Restore baseURL 
  NamedList status = (NamedList)namedListResponse.get("status");
  NamedList collectionStatus = (NamedList)status.get("collection1");
  String collectionSchema = (String)collectionStatus.get(CoreAdminParams.SCHEMA);
  // Make sure the upgrade to managed schema happened
  assertEquals("Schema resource name differs from expected name", "managed-schema", collectionSchema);

  SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), 30000);
  try {
    // Make sure "DO NOT EDIT" is in the content of the managed schema
    String fileContent = getFileContentFromZooKeeper(zkClient, "/solr/configs/conf1/managed-schema");
    assertTrue("Managed schema is missing", fileContent.contains("DO NOT EDIT"));

    // Make sure the original non-managed schema is no longer in ZooKeeper
    assertFileNotInZooKeeper(zkClient, "/solr/configs/conf1", "schema.xml");

    // Make sure the renamed non-managed schema is present in ZooKeeper
    fileContent = getFileContentFromZooKeeper(zkClient, "/solr/configs/conf1/schema.xml.bak");
    assertTrue("schema file doesn't contain '<schema'", fileContent.contains("<schema"));
  } finally {
    if (zkClient != null) {
      zkClient.close();
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:38,代码来源:TestCloudManagedSchema.java

示例3: getCount

import org.apache.solr.client.solrj.impl.HttpSolrServer; //导入方法依赖的package包/类
public long getCount(HttpSolrServer server, String core) {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("qt", "/select");
  params.set("q", "*:*");
  long numFound = 0;
  server.setBaseURL(baseUrl + core);
  try {
    QueryResponse response = server.query(params);
    numFound = response.getResults().getNumFound();
  } catch (Exception e) {
    e.printStackTrace();
  }
  return numFound;
}
 
开发者ID:europeana,项目名称:search,代码行数:15,代码来源:OpenCloseCoreStressTest.java


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