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


Java ResponseBuilder.getGroupingSpec方法代码示例

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


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

示例1: constructRequest

import org.apache.solr.handler.component.ResponseBuilder; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public ShardRequest[] constructRequest(ResponseBuilder rb) {
  ShardRequest sreq = new ShardRequest();
  GroupingSpecification groupingSpecification = rb.getGroupingSpec();
  if (groupingSpecification.getFields().length == 0) {
    return new ShardRequest[0];
  }

  sreq.purpose = ShardRequest.PURPOSE_GET_TOP_GROUPS;

  sreq.params = new ModifiableSolrParams(rb.req.getParams());
  // TODO: base on current params or original params?

  // don't pass through any shards param
  sreq.params.remove(ShardParams.SHARDS);

  // set the start (offset) to 0 for each shard request so we can properly merge
  // results from the start.
  if(rb.shards_start > -1) {
    // if the client set shards.start set this explicitly
    sreq.params.set(CommonParams.START,rb.shards_start);
  } else {
    sreq.params.set(CommonParams.START, "0");
  }
  // TODO: should we even use the SortSpec?  That's obtained from the QParser, and
  // perhaps we shouldn't attempt to parse the query at this level?
  // Alternate Idea: instead of specifying all these things at the upper level,
  // we could just specify that this is a shard request.
  if(rb.shards_rows > -1) {
    // if the client set shards.rows set this explicity
    sreq.params.set(CommonParams.ROWS,rb.shards_rows);
  } else {
    sreq.params.set(CommonParams.ROWS, rb.getSortSpec().getOffset() + rb.getSortSpec().getCount());
  }

  // in this first phase, request only the unique key field
  // and any fields needed for merging.
  sreq.params.set(GroupParams.GROUP_DISTRIBUTED_FIRST, "true");

  if ( (rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES)!=0 || rb.getSortSpec().includesScore()) {
    sreq.params.set(CommonParams.FL, rb.req.getSchema().getUniqueKeyField().getName() + ",score");
  } else {
    sreq.params.set(CommonParams.FL, rb.req.getSchema().getUniqueKeyField().getName());
  }
  return new ShardRequest[] {sreq};
}
 
开发者ID:europeana,项目名称:search,代码行数:50,代码来源:SearchGroupsRequestFactory.java


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