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


Java ShardParams.SHARD_KEYS属性代码示例

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


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

示例1: doHashingTest

private void doHashingTest() throws Exception {
  log.info("### STARTING doHashingTest");
  assertEquals(4, cloudClient.getZkStateReader().getClusterState().getCollection(DEFAULT_COLLECTION).getSlices().size());
  String shardKeys = ShardParams.SHARD_KEYS;
  // for now,  we know how ranges will be distributed to shards.
  // may have to look it up in clusterstate if that assumption changes.


  doAddDoc("b!doc1");
  doAddDoc("c!doc2");
  doAddDoc("d!doc3");
  doAddDoc("e!doc4");

  doRTG("b!doc1");
  doRTG("c!doc2");
  doRTG("d!doc3");
  doRTG("e!doc4");
  doRTG("b!doc1,c!doc2");
  doRTG("d!doc3,e!doc4");

  commit();

  doQuery("b!doc1,c!doc2,d!doc3,e!doc4", "q","*:*");
  doQuery("b!doc1,c!doc2,d!doc3,e!doc4", "q","*:*", "shards","shard1,shard2,shard3,shard4");
  doQuery("b!doc1,c!doc2,d!doc3,e!doc4", "q","*:*", shardKeys,"b!,c!,d!,e!");
  doQuery("b!doc1", "q","*:*", shardKeys,"b!");
  doQuery("c!doc2", "q","*:*", shardKeys,"c!");
  doQuery("d!doc3", "q","*:*", shardKeys,"d!");
  doQuery("e!doc4", "q","*:*", shardKeys,"e!");

  // try using shards parameter
  doQuery("b!doc1", "q","*:*", "shards",bucket1);
  doQuery("c!doc2", "q","*:*", "shards",bucket2);
  doQuery("d!doc3", "q","*:*", "shards",bucket3);
  doQuery("e!doc4", "q","*:*", "shards",bucket4);


  doQuery("b!doc1,c!doc2", "q","*:*", shardKeys,"b!,c!");
  doQuery("b!doc1,e!doc4", "q","*:*", shardKeys,"b!,e!");

  doQuery("b!doc1,c!doc2", "q","*:*", shardKeys,"b,c");     // query shards that would contain *documents* "b" and "c" (i.e. not prefixes).  The upper bits are the same, so the shards should be the same.

  doQuery("b!doc1,c!doc2", "q","*:*", shardKeys,"b/1!");   // top bit of hash(b)==1, so shard1 and shard2
  doQuery("d!doc3,e!doc4", "q","*:*", shardKeys,"d/1!");   // top bit of hash(b)==0, so shard3 and shard4

  doQuery("b!doc1,c!doc2", "q","*:*", shardKeys,"b!,c!");

  doQuery("b!doc1,c!doc2,d!doc3,e!doc4", "q","*:*", shardKeys,"foo/0!");

  // test targeting deleteByQuery at only certain shards
  doDBQ("*:*", shardKeys,"b!");
  commit();
  doQuery("c!doc2,d!doc3,e!doc4", "q","*:*");
  doAddDoc("b!doc1");

  doDBQ("*:*", shardKeys,"c!");
  commit();
  doQuery("b!doc1,d!doc3,e!doc4", "q","*:*");
  doAddDoc("c!doc2");

  doDBQ("*:*", shardKeys,"c!");
  commit();
  doQuery("b!doc1,d!doc3,e!doc4", "q","*:*");
  doAddDoc("c!doc2");

  doDBQ("*:*", shardKeys,"d!,e!");
  commit();
  doQuery("b!doc1,c!doc2", "q","*:*");
  doAddDoc("d!doc3");
  doAddDoc("e!doc4");

  commit();
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:73,代码来源:ShardRoutingTest.java


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