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


Java SolrParams.wrapAppended方法代码示例

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


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

示例1: assertPivotCountsAreCorrect

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/**
 * Recursive Helper method for asserting that pivot constraint counds match
 * results when filtering on those constraints. Returns the recursive depth reached 
 * (for sanity checking)
 */
private int assertPivotCountsAreCorrect(String pivotName,
                                        SolrParams baseParams, 
                                        PivotField constraint) 
  throws SolrServerException {

  SolrParams p = SolrParams.wrapAppended(baseParams,
                                         params("fq", buildFilter(constraint)));
  List<PivotField> subPivots = null;
  try {
    assertNumFound(pivotName, constraint.getCount(), p);
    subPivots = constraint.getPivot();
  } catch (Exception e) {
    throw new RuntimeException(pivotName + ": count query failed: " + p + ": " + 
                               e.getMessage(), e);
  }
  int depth = 0;
  if (null != subPivots) {
    assertTraceOk(pivotName, baseParams, subPivots);

    for (PivotField subPivot : subPivots) {
      depth = assertPivotCountsAreCorrect(pivotName, p, subPivot);
    }
  }
  return depth + 1;
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:TestCloudPivotFacet.java

示例2: testSolrParams

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
@Test
public void testSolrParams() throws Exception {
  NamedList nl = new NamedList();
  nl.add("i",555);
  nl.add("s","bbb");
  nl.add("bt","true");
  nl.add("bf","false");

  Map<String,String> m = new HashMap<>();
  m.put("f.field1.i", "1000");
  m.put("s", "BBB");
  m.put("ss", "SSS");

  LocalSolrQueryRequest req = new LocalSolrQueryRequest(null,nl);
  SolrParams p = req.getParams();

  assertEquals(p.get("i"), "555");
  assertEquals(p.getInt("i").intValue(), 555);
  assertEquals(p.getInt("i",5), 555);
  assertEquals(p.getInt("iii",5), 5);
  assertEquals(p.getFieldParam("field1","i"), "555");

  req.setParams(SolrParams.wrapDefaults(p, new MapSolrParams(m)));
  p = req.getParams();
  assertEquals(req.getOriginalParams().get("s"), "bbb");
  assertEquals(p.get("i"), "555");
  assertEquals(p.getInt("i").intValue(), 555);
  assertEquals(p.getInt("i",5), 555);
  assertEquals(p.getInt("iii",5), 5);

  assertEquals(p.getFieldParam("field1","i"), "1000");
  assertEquals(p.get("s"), "bbb");
  assertEquals(p.get("ss"), "SSS");

  assertEquals(!!p.getBool("bt"), !p.getBool("bf"));
  assertEquals(p.getBool("foo",true), true);
  assertEquals(p.getBool("foo",false), false);
  assertEquals(!!p.getBool("bt"), !p.getBool("bf"));

  NamedList more = new NamedList();
  more.add("s", "aaa");
  more.add("s", "ccc");
  more.add("ss","YYY");
  more.add("xx","XXX");
  p = SolrParams.wrapAppended(p, SolrParams.toSolrParams(more));
  assertEquals(3, p.getParams("s").length);
  assertEquals("bbb", p.getParams("s")[0]);
  assertEquals("aaa", p.getParams("s")[1]);
  assertEquals("ccc", p.getParams("s")[2]);
  assertEquals(3, p.getParams("s").length);
  assertEquals("SSS", p.get("ss"));
  assertEquals("XXX", p.get("xx"));

  req.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:56,代码来源:BasicFunctionalityTest.java

示例3: setDefaults

import org.apache.solr.common.params.SolrParams; //导入方法依赖的package包/类
/**
 * Set default-ish params on a SolrQueryRequest.
 *
 * RequestHandlers can use this method to ensure their defaults and
 * overrides are visible to other components such as the response writer
 *
 * @param req The request whose params we are interested i
 * @param defaults values to be used if no values are specified in the request params
 * @param appends values to be appended to those from the request (or defaults) when dealing with multi-val params, or treated as another layer of defaults for singl-val params.
 * @param invariants values which will be used instead of any request, or default values, regardless of context.
 */
public static void setDefaults(SolrQueryRequest req, SolrParams defaults,
                               SolrParams appends, SolrParams invariants) {

    SolrParams p = req.getParams();
    p = SolrParams.wrapDefaults(p, defaults);
    p = SolrParams.wrapAppended(p, appends);
    p = SolrParams.wrapDefaults(invariants, p);

    req.setParams(p);
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:SolrPluginUtils.java


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