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


Java FacetInterval类代码示例

本文整理汇总了Java中org.apache.solr.request.IntervalFacets.FacetInterval的典型用法代码示例。如果您正苦于以下问题:Java FacetInterval类的具体用法?Java FacetInterval怎么用?Java FacetInterval使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: accumIntervalsSingle

import org.apache.solr.request.IntervalFacets.FacetInterval; //导入依赖的package包/类
private void accumIntervalsSingle(SortedDocValues sdv, DocIdSetIterator disi, Bits bits) throws IOException {
  // First update the ordinals in the intervals to this segment
  for (FacetInterval interval : intervals) {
    interval.updateContext(sdv);
  }
  int doc;
  while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
    if (bits != null && bits.get(doc) == false) {
      continue;
    }
    int ord = sdv.getOrd(doc);
    if (ord >= 0) {
      accumInterval(ord);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:IntervalFacets.java

示例2: getFacetIntervalCounts

import org.apache.solr.request.IntervalFacets.FacetInterval; //导入依赖的package包/类
/**
 * Returns a <code>NamedList</code> with each entry having the "key" of the interval as name and the count of docs 
 * in that interval as value. All intervals added in the request are included in the returned 
 * <code>NamedList</code> (included those with 0 count), and it's required that the order of the intervals
 * is deterministic and equals in all shards of a distributed request, otherwise the collation of results
 * will fail. 
 * 
 */
public NamedList<Object> getFacetIntervalCounts() throws IOException, SyntaxError {
  NamedList<Object> res = new SimpleOrderedMap<Object>();
  String[] fields = global.getParams(FacetParams.FACET_INTERVAL);
  if (fields == null || fields.length == 0) return res;

  for (String field : fields) {
    final ParsedParams parsed = parseParams(FacetParams.FACET_INTERVAL, field);
    String[] intervalStrs = parsed.required.getFieldParams(parsed.facetValue, FacetParams.FACET_INTERVAL_SET);
    SchemaField schemaField = searcher.getCore().getLatestSchema().getField(parsed.facetValue);
    if (parsed.params.getBool(GroupParams.GROUP_FACET, false)) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Interval Faceting can't be used with " + GroupParams.GROUP_FACET);
    }
    if (schemaField.getType().isPointField() && !schemaField.hasDocValues()) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Can't use interval faceting on a PointField without docValues");
    }
    
    SimpleOrderedMap<Integer> fieldResults = new SimpleOrderedMap<Integer>();
    res.add(parsed.key, fieldResults);
    IntervalFacets intervalFacets = new IntervalFacets(schemaField, searcher, parsed.docs, intervalStrs, parsed.params);
    for (FacetInterval interval : intervalFacets) {
      fieldResults.add(interval.getKey(), interval.getCount());
    }
  }

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

示例3: getFacetIntervalCounts

import org.apache.solr.request.IntervalFacets.FacetInterval; //导入依赖的package包/类
/**
 * Returns a <code>NamedList</code> with each entry having the "key" of the interval as name and the count of docs 
 * in that interval as value. All intervals added in the request are included in the returned 
 * <code>NamedList</code> (included those with 0 count), and it's required that the order of the intervals
 * is deterministic and equals in all shards of a distributed request, otherwise the collation of results
 * will fail. 
 * 
 */
public NamedList<Object> getFacetIntervalCounts() throws IOException, SyntaxError {
  NamedList<Object> res = new SimpleOrderedMap<Object>();
  String[] fields = params.getParams(FacetParams.FACET_INTERVAL);
  if (fields == null || fields.length == 0) return res;

  for (String field : fields) {
    parseParams(FacetParams.FACET_INTERVAL, field);
    String[] intervalStrs = required.getFieldParams(field, FacetParams.FACET_INTERVAL_SET);
    SchemaField schemaField = searcher.getCore().getLatestSchema().getField(field);
    if (!schemaField.hasDocValues()) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Interval Faceting only on fields with doc values");
    }
    if (params.getBool(GroupParams.GROUP_FACET, false)) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Interval Faceting can't be used with " + GroupParams.GROUP_FACET);
    }
    
    SimpleOrderedMap<Integer> fieldResults = new SimpleOrderedMap<Integer>();
    res.add(field, fieldResults);
    IntervalFacets intervalFacets = new IntervalFacets(schemaField, searcher, docs, intervalStrs, params);
    for (FacetInterval interval : intervalFacets) {
      fieldResults.add(interval.getKey(), interval.getCount());
    }
  }

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

示例4: getSortedIntervals

import org.apache.solr.request.IntervalFacets.FacetInterval; //导入依赖的package包/类
private FacetInterval[] getSortedIntervals(String[] intervals, SolrParams params) throws SyntaxError {
  FacetInterval[] sortedIntervals = new FacetInterval[intervals.length];
  int idx = 0;
  for (String intervalStr : intervals) {
    sortedIntervals[idx++] = new FacetInterval(schemaField, intervalStr, params);
  }
  
  /*
   * This comparator sorts the intervals by start value from lower to greater
   */
  Arrays.sort(sortedIntervals, new Comparator<FacetInterval>() {

    @Override
    public int compare(FacetInterval o1, FacetInterval o2) {
      assert o1 != null;
      assert o2 != null;
      return compareStart(o1, o2);
    }

    private int compareStart(FacetInterval o1, FacetInterval o2) {
      if (o1.start == null) {
        if (o2.start == null) {
          return 0;
        }
        return -1;
      }
      if (o2.start == null) {
        return 1;
      }
      return o1.start.compareTo(o2.start);
    }
  });
  return sortedIntervals;
}
 
开发者ID:europeana,项目名称:search,代码行数:35,代码来源:IntervalFacets.java

示例5: accumIntervalWithValue

import org.apache.solr.request.IntervalFacets.FacetInterval; //导入依赖的package包/类
private void accumIntervalWithValue(long value) {
  for (int i = 0; i < intervals.length; i++) {
    FacetInterval interval = intervals[i];
    IntervalCompareResult result = interval.includes(value);
    if (result == IntervalCompareResult.INCLUDED) {
      interval.incCount();
    } else if (result == IntervalCompareResult.LOWER_THAN_START) {
      // All intervals after this will have equal or grater start value, 
      // we can skip them
      break;
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:IntervalFacets.java

示例6: assertStringInterval

import org.apache.solr.request.IntervalFacets.FacetInterval; //导入依赖的package包/类
private void assertStringInterval(String fieldName, String intervalStr,
                                  String expectedStart, String expectedEnd) throws SyntaxError {
  SchemaField f = h.getCore().getLatestSchema().getField(fieldName);
  FacetInterval interval = new FacetInterval(f, intervalStr, new ModifiableSolrParams());

  assertEquals("Expected start " + expectedStart + " but found " + f.getType().toObject(f, interval.start),
      interval.start, new BytesRef(f.getType().toInternal(expectedStart)));

  assertEquals("Expected end " + expectedEnd + " but found " + f.getType().toObject(f, interval.end),
      interval.end, new BytesRef(f.getType().toInternal(expectedEnd)));
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:TestIntervalFaceting.java

示例7: assertBadInterval

import org.apache.solr.request.IntervalFacets.FacetInterval; //导入依赖的package包/类
private void assertBadInterval(String fieldName, String intervalStr, String errorMsg) {
  SchemaField f = h.getCore().getLatestSchema().getField(fieldName);
  try {
    new FacetInterval(f, intervalStr, new ModifiableSolrParams());
    fail("Expecting SyntaxError for interval String: " + intervalStr);
  } catch (SyntaxError e) {
    assertTrue("Unexpected error message for interval String: " + intervalStr + ": " +
        e.getMessage(), e.getMessage().contains(errorMsg));
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:TestIntervalFaceting.java

示例8: accumIntervalsMulti

import org.apache.solr.request.IntervalFacets.FacetInterval; //导入依赖的package包/类
private void accumIntervalsMulti(SortedSetDocValues ssdv,
                                 DocIdSetIterator disi, Bits bits) throws IOException {
  // First update the ordinals in the intervals for this segment
  for (FacetInterval interval : intervals) {
    interval.updateContext(ssdv);
  }

  int doc;
  while ((doc = disi.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
    if (bits != null && bits.get(doc) == false) {
      continue;
    }
    ssdv.setDocument(doc);
    long currOrd;
    int currentInterval = 0;
    while ((currOrd = ssdv.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {
      boolean evaluateNextInterval = true;
      while (evaluateNextInterval && currentInterval < intervals.length) {
        IntervalCompareResult result = intervals[currentInterval].includes(currOrd);
        switch (result) {
          case INCLUDED:
            /*
             * Increment the current interval and move to the next one using
             * the same value
             */
            intervals[currentInterval].incCount();
            currentInterval++;
            break;
          case LOWER_THAN_START:
            /*
             * None of the next intervals will match this value (all of them have 
             * higher start value). Move to the next value for this document. 
             */
            evaluateNextInterval = false;
            break;
          case GREATER_THAN_END:
            /*
             * Next interval may match this value
             */
            currentInterval++;
            break;
        }
      }
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:47,代码来源:IntervalFacets.java

示例9: iterator

import org.apache.solr.request.IntervalFacets.FacetInterval; //导入依赖的package包/类
/**
 * Iterate over all the intervals
 */
@Override
public Iterator<FacetInterval> iterator() {

  return new ArrayList<FacetInterval>(Arrays.asList(intervals)).iterator();
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:IntervalFacets.java


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