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


Java ResponseBuilder.getFieldFlags方法代码示例

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


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

示例1: process

import org.apache.solr.handler.component.ResponseBuilder; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void process(ResponseBuilder rb, ShardRequest shardRequest) {
  boolean returnScores = (rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES) != 0;
  ShardResponse srsp = shardRequest.responses.get(0);
  SolrDocumentList docs = (SolrDocumentList)srsp.getSolrResponse().getResponse().get("response");
  String uniqueIdFieldName = rb.req.getSchema().getUniqueKeyField().getName();

  for (SolrDocument doc : docs) {
    Object id = doc.getFieldValue(uniqueIdFieldName).toString();
    ShardDoc shardDoc = rb.resultIds.get(id);
    FieldDoc fieldDoc = (FieldDoc) shardDoc;
    if (shardDoc != null) {
      if (returnScores && !Float.isNaN(fieldDoc.score)) {
          doc.setField("score", fieldDoc.score);
      }
      rb.retrievedDocuments.put(id, doc);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:StoredFieldsShardResponseProcessor.java

示例2: createRequest

import org.apache.solr.handler.component.ResponseBuilder; //导入方法依赖的package包/类
private ShardRequest[] createRequest(ResponseBuilder rb, String[] shards)
{
  ShardRequest sreq = new ShardRequest();
  sreq.shards = shards;
  sreq.purpose = ShardRequest.PURPOSE_GET_TOP_IDS;
  sreq.params = new ModifiableSolrParams(rb.req.getParams());

  // If group.format=simple group.offset doesn't make sense
  Grouping.Format responseFormat = rb.getGroupingSpec().getResponseFormat();
  if (responseFormat == Grouping.Format.simple || rb.getGroupingSpec().isMain()) {
    sreq.params.remove(GroupParams.GROUP_OFFSET);
  }

  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");
  }
  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());
  }

  sreq.params.set(GroupParams.GROUP_DISTRIBUTED_SECOND, "true");
  final IndexSchema schema = rb.req.getSearcher().getSchema();
  for (Map.Entry<String, Collection<SearchGroup<BytesRef>>> entry : rb.mergedSearchGroups.entrySet()) {
    for (SearchGroup<BytesRef> searchGroup : entry.getValue()) {
      String groupValue;
      if (searchGroup.groupValue != null) {
        String rawGroupValue = searchGroup.groupValue.utf8ToString();
        FieldType fieldType = schema.getField(entry.getKey()).getType();
        groupValue = fieldType.indexedToReadable(rawGroupValue);
      } else {
        groupValue = GROUP_NULL_VALUE;
      }
      sreq.params.add(GroupParams.GROUP_DISTRIBUTED_TOPGROUPS_PREFIX + entry.getKey(), groupValue);
    }
  }

  if ((rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES) != 0 || rb.getSortSpec().includesScore()) {
    sreq.params.set(CommonParams.FL, schema.getUniqueKeyField().getName() + ",score");
  } else {
    sreq.params.set(CommonParams.FL, schema.getUniqueKeyField().getName());
  }
  
  int origTimeAllowed = sreq.params.getInt(CommonParams.TIME_ALLOWED, -1);
  if (origTimeAllowed > 0) {
    sreq.params.set(CommonParams.TIME_ALLOWED, Math.max(1,origTimeAllowed - rb.firstPhaseElapsedTime));
  }

  return new ShardRequest[] {sreq};
}
 
开发者ID:europeana,项目名称:search,代码行数:60,代码来源:TopGroupsShardRequestFactory.java

示例3: 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

示例4: createRequest

import org.apache.solr.handler.component.ResponseBuilder; //导入方法依赖的package包/类
private ShardRequest[] createRequest(ResponseBuilder rb, String[] shards)
{
  ShardRequest sreq = new ShardRequest();
  sreq.shards = shards;
  sreq.purpose = ShardRequest.PURPOSE_GET_TOP_IDS;
  sreq.params = new ModifiableSolrParams(rb.req.getParams());

  // If group.format=simple group.offset doesn't make sense
  Grouping.Format responseFormat = rb.getGroupingSpec().getResponseFormat();
  if (responseFormat == Grouping.Format.simple || rb.getGroupingSpec().isMain()) {
    sreq.params.remove(GroupParams.GROUP_OFFSET);
  }

  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");
  }
  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());
  }

  sreq.params.set(GroupParams.GROUP_DISTRIBUTED_SECOND, "true");
  for (Map.Entry<String, Collection<SearchGroup<BytesRef>>> entry : rb.mergedSearchGroups.entrySet()) {
    for (SearchGroup<BytesRef> searchGroup : entry.getValue()) {
      String groupValue;
      if (searchGroup.groupValue != null) {
        String rawGroupValue = searchGroup.groupValue.utf8ToString();
        FieldType fieldType = rb.req.getSearcher().getSchema().getField(entry.getKey()).getType();
        groupValue = fieldType.indexedToReadable(rawGroupValue);
      } else {
        groupValue = GROUP_NULL_VALUE;
      }
      sreq.params.add(GroupParams.GROUP_DISTRIBUTED_TOPGROUPS_PREFIX + entry.getKey(), groupValue);
    }
  }

  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());
  }
  
  int origTimeAllowed = sreq.params.getInt(CommonParams.TIME_ALLOWED, -1);
  if (origTimeAllowed > 0) {
    sreq.params.set(CommonParams.TIME_ALLOWED, Math.max(1,origTimeAllowed - rb.firstPhaseElapsedTime));
  }

  return new ShardRequest[] {sreq};
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:59,代码来源:TopGroupsShardRequestFactory.java


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