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


Java FieldType.indexedToReadable方法代码示例

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


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

示例1: writeFieldVal

import org.apache.solr.schema.FieldType; //导入方法依赖的package包/类
static void writeFieldVal(BytesRef val, FieldType ft, Appendable out, int flags) throws IOException {
  if (ft != null) {
    try {
      CharsRef readable = new CharsRef();
      ft.indexedToReadable(val, readable);
      out.append(readable);
    } catch (Exception e) {
      out.append("EXCEPTION(val=");
      out.append(val.utf8ToString());
      out.append(")");
    }
  } else {
    out.append(val.utf8ToString());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:QueryParsing.java

示例2: getGroupedCounts

import org.apache.solr.schema.FieldType; //导入方法依赖的package包/类
public NamedList<Integer> getGroupedCounts(SolrIndexSearcher searcher,
                                           DocSet base,
                                           String field,
                                           boolean multiToken,
                                           int offset,
                                           int limit,
                                           int mincount,
                                           boolean missing,
                                           String sort,
                                           String prefix) throws IOException {
  GroupingSpecification groupingSpecification = rb.getGroupingSpec();
  String groupField  = groupingSpecification != null ? groupingSpecification.getFields()[0] : null;
  if (groupField == null) {
    throw new SolrException (
        SolrException.ErrorCode.BAD_REQUEST,
        "Specify the group.field as parameter or local parameter"
    );
  }

  BytesRef prefixBR = prefix != null ? new BytesRef(prefix) : null;
  TermGroupFacetCollector collector = TermGroupFacetCollector.createTermGroupFacetCollector(groupField, field, multiToken, prefixBR, 128);
  searcher.search(new MatchAllDocsQuery(), base.getTopFilter(), collector);
  boolean orderByCount = sort.equals(FacetParams.FACET_SORT_COUNT) || sort.equals(FacetParams.FACET_SORT_COUNT_LEGACY);
  TermGroupFacetCollector.GroupedFacetResult result = collector.mergeSegmentResults(offset + limit, mincount, orderByCount);

  CharsRef charsRef = new CharsRef();
  FieldType facetFieldType = searcher.getSchema().getFieldType(field);
  NamedList<Integer> facetCounts = new NamedList<Integer>();
  List<TermGroupFacetCollector.FacetEntry> scopedEntries = result.getFacetEntries(offset, limit);
  for (TermGroupFacetCollector.FacetEntry facetEntry : scopedEntries) {
    facetFieldType.indexedToReadable(facetEntry.getValue(), charsRef);
    facetCounts.add(charsRef.toString(), facetEntry.getCount());
  }

  if (missing) {
    facetCounts.add(null, result.getTotalMissingCount());
  }

  return facetCounts;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:41,代码来源:SimpleFacets.java

示例3: getGroupedCounts

import org.apache.solr.schema.FieldType; //导入方法依赖的package包/类
public NamedList<Integer> getGroupedCounts(SolrIndexSearcher searcher,
                                           DocSet base,
                                           String field,
                                           boolean multiToken,
                                           int offset,
                                           int limit,
                                           int mincount,
                                           boolean missing,
                                           String sort,
                                           String prefix,
                                           Predicate<BytesRef> termFilter) throws IOException {
  GroupingSpecification groupingSpecification = rb.getGroupingSpec();
  final String groupField  = groupingSpecification != null ? groupingSpecification.getFields()[0] : null;
  if (groupField == null) {
    throw new SolrException (
        SolrException.ErrorCode.BAD_REQUEST,
        "Specify the group.field as parameter or local parameter"
    );
  }

  BytesRef prefixBytesRef = prefix != null ? new BytesRef(prefix) : null;
  final TermGroupFacetCollector collector = TermGroupFacetCollector.createTermGroupFacetCollector(groupField, field, multiToken, prefixBytesRef, 128);
  
  Collector groupWrapper = getInsanityWrapper(groupField, collector);
  Collector fieldWrapper = getInsanityWrapper(field, groupWrapper);
  // When GroupedFacetCollector can handle numerics we can remove the wrapped collectors
  searcher.search(base.getTopFilter(), fieldWrapper);
  
  boolean orderByCount = sort.equals(FacetParams.FACET_SORT_COUNT) || sort.equals(FacetParams.FACET_SORT_COUNT_LEGACY);
  TermGroupFacetCollector.GroupedFacetResult result 
    = collector.mergeSegmentResults(limit < 0 ? Integer.MAX_VALUE : 
                                    (offset + limit), 
                                    mincount, orderByCount);

  CharsRefBuilder charsRef = new CharsRefBuilder();
  FieldType facetFieldType = searcher.getSchema().getFieldType(field);
  NamedList<Integer> facetCounts = new NamedList<>();
  List<TermGroupFacetCollector.FacetEntry> scopedEntries 
    = result.getFacetEntries(offset, limit < 0 ? Integer.MAX_VALUE : limit);
  for (TermGroupFacetCollector.FacetEntry facetEntry : scopedEntries) {
    //:TODO:can we filter earlier than this to make it more efficient?
    if (termFilter != null && !termFilter.test(facetEntry.getValue())) {
      continue;
    }
    facetFieldType.indexedToReadable(facetEntry.getValue(), charsRef);
    facetCounts.add(charsRef.toString(), facetEntry.getCount());
  }

  if (missing) {
    facetCounts.add(null, result.getTotalMissingCount());
  }

  return facetCounts;
}
 
开发者ID:upenn-libraries,项目名称:solrplugins,代码行数:55,代码来源:SimpleFacets.java

示例4: getGroupedCounts

import org.apache.solr.schema.FieldType; //导入方法依赖的package包/类
public NamedList<Integer> getGroupedCounts(SolrIndexSearcher searcher,
                                           DocSet base,
                                           String field,
                                           boolean multiToken,
                                           int offset,
                                           int limit,
                                           int mincount,
                                           boolean missing,
                                           String sort,
                                           String prefix) throws IOException {
  GroupingSpecification groupingSpecification = rb.getGroupingSpec();
  String groupField  = groupingSpecification != null ? groupingSpecification.getFields()[0] : null;
  if (groupField == null) {
    throw new SolrException (
        SolrException.ErrorCode.BAD_REQUEST,
        "Specify the group.field as parameter or local parameter"
    );
  }

  BytesRef prefixBR = prefix != null ? new BytesRef(prefix) : null;
  TermGroupFacetCollector collector = TermGroupFacetCollector.createTermGroupFacetCollector(groupField, field, multiToken, prefixBR, 128);
  searcher.search(new MatchAllDocsQuery(), base.getTopFilter(), collector);
  boolean orderByCount = sort.equals(FacetParams.FACET_SORT_COUNT) || sort.equals(FacetParams.FACET_SORT_COUNT_LEGACY);
  TermGroupFacetCollector.GroupedFacetResult result 
    = collector.mergeSegmentResults(limit < 0 ? Integer.MAX_VALUE : 
                                    (offset + limit), 
                                    mincount, orderByCount);

  CharsRef charsRef = new CharsRef();
  FieldType facetFieldType = searcher.getSchema().getFieldType(field);
  NamedList<Integer> facetCounts = new NamedList<>();
  List<TermGroupFacetCollector.FacetEntry> scopedEntries 
    = result.getFacetEntries(offset, limit < 0 ? Integer.MAX_VALUE : limit);
  for (TermGroupFacetCollector.FacetEntry facetEntry : scopedEntries) {
    facetFieldType.indexedToReadable(facetEntry.getValue(), charsRef);
    facetCounts.add(charsRef.toString(), facetEntry.getCount());
  }

  if (missing) {
    facetCounts.add(null, result.getTotalMissingCount());
  }

  return facetCounts;
}
 
开发者ID:europeana,项目名称:search,代码行数:45,代码来源:SimpleFacets.java

示例5: finish

import org.apache.solr.schema.FieldType; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void finish() throws IOException {
  result = secondPass != null ? secondPass.getTopGroups(0) : null;
  if (main) {
    mainResult = createSimpleResponse();
    return;
  }

  NamedList groupResult = commonResponse();

  if (format == Format.simple) {
    groupResult.add("doclist", createSimpleResponse());
    return;
  }

  List groupList = new ArrayList();
  groupResult.add("groups", groupList);        // grouped={ key={ groups=[

  if (result == null) {
    return;
  }

  // handle case of rows=0
  if (numGroups == 0) return;

  for (GroupDocs<BytesRef> group : result.groups) {
    NamedList nl = new SimpleOrderedMap();
    groupList.add(nl);                         // grouped={ key={ groups=[ {


    // To keep the response format compatable with trunk.
    // In trunk MutableValue can convert an indexed value to its native type. E.g. string to int
    // The only option I currently see is the use the FieldType for this
    if (group.groupValue != null) {
      SchemaField schemaField = searcher.getSchema().getField(groupBy);
      FieldType fieldType = schemaField.getType();
      String readableValue = fieldType.indexedToReadable(group.groupValue.utf8ToString());
      IndexableField field = schemaField.createField(readableValue, 1.0f);
      nl.add("groupValue", fieldType.toObject(field));
    } else {
      nl.add("groupValue", null);
    }

    addDocList(nl, group);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:50,代码来源:Grouping.java

示例6: createRequest

import org.apache.solr.schema.FieldType; //导入方法依赖的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

示例7: createRequest

import org.apache.solr.schema.FieldType; //导入方法依赖的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

示例8: getGroupedCounts

import org.apache.solr.schema.FieldType; //导入方法依赖的package包/类
public NamedList<Integer> getGroupedCounts(SolrIndexSearcher searcher,
                                           DocSet base,
                                           String field,
                                           boolean multiToken,
                                           int offset,
                                           int limit,
                                           int mincount,
                                           boolean missing,
                                           String sort,
                                           String prefix) throws IOException {
  GroupingSpecification groupingSpecification = rb.getGroupingSpec();
  String groupField  = groupingSpecification != null ? groupingSpecification.getFields()[0] : null;
  if (groupField == null) {
    throw new SolrException (
        SolrException.ErrorCode.BAD_REQUEST,
        "Specify the group.field as parameter or local parameter"
    );
  }

  BytesRef prefixBR = prefix != null ? new BytesRef(prefix) : null;
  TermGroupFacetCollector collector = TermGroupFacetCollector.createTermGroupFacetCollector(groupField, field, multiToken, prefixBR, 128);
  searcher.search(new MatchAllDocsQuery(), base.getTopFilter(), collector);
  boolean orderByCount = sort.equals(FacetParams.FACET_SORT_COUNT) || sort.equals(FacetParams.FACET_SORT_COUNT_LEGACY);
  TermGroupFacetCollector.GroupedFacetResult result 
    = collector.mergeSegmentResults(limit < 0 ? Integer.MAX_VALUE : 
                                    (offset + limit), 
                                    mincount, orderByCount);

  CharsRef charsRef = new CharsRef();
  FieldType facetFieldType = searcher.getSchema().getFieldType(field);
  NamedList<Integer> facetCounts = new NamedList<Integer>();
  List<TermGroupFacetCollector.FacetEntry> scopedEntries 
    = result.getFacetEntries(offset, limit < 0 ? Integer.MAX_VALUE : limit);
  for (TermGroupFacetCollector.FacetEntry facetEntry : scopedEntries) {
    facetFieldType.indexedToReadable(facetEntry.getValue(), charsRef);
    facetCounts.add(charsRef.toString(), facetEntry.getCount());
  }

  if (missing) {
    facetCounts.add(null, result.getTotalMissingCount());
  }

  return facetCounts;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:45,代码来源:SimpleFacets.java


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