Java 类org.apache.lucene.search.grouping.term.TermAllGroupsCollector 实例源码

项目:solrplugins    文件:SimpleFacets.java   
/**
 * Returns a grouped facet count for the facet query
 *
 * @see FacetParams#FACET_QUERY
 */
public int getGroupedFacetQueryCount(Query facetQuery, DocSet docSet) throws IOException {
  // It is okay to retrieve group.field from global because it is never a local param
  String groupField = global.get(GroupParams.GROUP_FIELD);
  if (groupField == null) {
    throw new SolrException (
        SolrException.ErrorCode.BAD_REQUEST,
        "Specify the group.field as parameter or local parameter"
    );
  }

  TermAllGroupsCollector collector = new TermAllGroupsCollector(groupField);
  Filter mainQueryFilter = docSet.getTopFilter(); // This returns a filter that only matches documents matching with q param and fq params
  Query filteredFacetQuery = new BooleanQuery.Builder()
      .add(facetQuery, Occur.MUST)
      .add(mainQueryFilter, Occur.FILTER)
      .build();
  searcher.search(filteredFacetQuery, collector);
  return collector.getGroupCount();
}
项目:NYBC    文件:SimpleFacets.java   
/**
 * Returns a grouped facet count for the facet query
 *
 * @see FacetParams#FACET_QUERY
 */
public int getGroupedFacetQueryCount(Query facetQuery) 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"
    );
  }

  TermAllGroupsCollector collector = new TermAllGroupsCollector(groupField);
  Filter mainQueryFilter = docs.getTopFilter(); // This returns a filter that only matches documents matching with q param and fq params
  searcher.search(facetQuery, mainQueryFilter, collector);
  return collector.getGroupCount();
}
项目:search-core    文件:SimpleFacets.java   
/**
 * Returns a grouped facet count for the facet query
 *
 * @see FacetParams#FACET_QUERY
 */
public int getGroupedFacetQueryCount(Query facetQuery) 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"
    );
  }

  TermAllGroupsCollector collector = new TermAllGroupsCollector(groupField);
  Filter mainQueryFilter = docs.getTopFilter(); // This returns a filter that only matches documents matching with q param and fq params
  searcher.search(facetQuery, mainQueryFilter, collector);
  return collector.getGroupCount();
}
项目:read-open-source-code    文件:SimpleFacets.java   
/**
 * Returns a grouped facet count for the facet query
 *
 * @see FacetParams#FACET_QUERY
 */
public int getGroupedFacetQueryCount(Query facetQuery) 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"
    );
  }

  TermAllGroupsCollector collector = new TermAllGroupsCollector(groupField);
  Filter mainQueryFilter = docs.getTopFilter(); // This returns a filter that only matches documents matching with q param and fq params
  searcher.search(facetQuery, mainQueryFilter, collector);
  return collector.getGroupCount();
}
项目:search    文件:TestGrouping.java   
private AbstractAllGroupsCollector<?> createAllGroupsCollector(AbstractFirstPassGroupingCollector<?> firstPassGroupingCollector,
                                                            String groupField) {
  if (firstPassGroupingCollector.getClass().isAssignableFrom(TermFirstPassGroupingCollector.class)) {
    return new TermAllGroupsCollector(groupField);
  } else {
    ValueSource vs = new BytesRefFieldSource(groupField);
    return new FunctionAllGroupsCollector(vs, new HashMap<>());
  }
}
项目:search    文件:SimpleFacets.java   
/**
 * Returns a grouped facet count for the facet query
 *
 * @see FacetParams#FACET_QUERY
 */
public int getGroupedFacetQueryCount(Query facetQuery) throws IOException {
  String groupField = params.get(GroupParams.GROUP_FIELD);
  if (groupField == null) {
    throw new SolrException (
        SolrException.ErrorCode.BAD_REQUEST,
        "Specify the group.field as parameter or local parameter"
    );
  }

  TermAllGroupsCollector collector = new TermAllGroupsCollector(groupField);
  Filter mainQueryFilter = docs.getTopFilter(); // This returns a filter that only matches documents matching with q param and fq params
  searcher.search(facetQuery, mainQueryFilter, collector);
  return collector.getGroupCount();
}
项目:search    文件:SearchGroupsFieldCommand.java   
@Override
public List<Collector> create() throws IOException {
  List<Collector> collectors = new ArrayList<>();
  if (topNGroups > 0) {
    firstPassGroupingCollector = new TermFirstPassGroupingCollector(field.getName(), groupSort, topNGroups);
    collectors.add(firstPassGroupingCollector);
  }
  if (includeGroupCount) {
    allGroupsCollector = new TermAllGroupsCollector(field.getName());
    collectors.add(allGroupsCollector);
  }
  return collectors;
}
项目:NYBC    文件:TestGrouping.java   
private AbstractAllGroupsCollector<?> createAllGroupsCollector(AbstractFirstPassGroupingCollector<?> firstPassGroupingCollector,
                                                            String groupField) {
  if (firstPassGroupingCollector.getClass().isAssignableFrom(TermFirstPassGroupingCollector.class)) {
    return new TermAllGroupsCollector(groupField);
  } else {
    ValueSource vs = new BytesRefFieldSource(groupField);
    return new FunctionAllGroupsCollector(vs, new HashMap<Object, Object>());
  }
}
项目:NYBC    文件:SearchGroupsFieldCommand.java   
@Override
public List<Collector> create() throws IOException {
  List<Collector> collectors = new ArrayList<Collector>();
  if (topNGroups > 0) {
    firstPassGroupingCollector = new TermFirstPassGroupingCollector(field.getName(), groupSort, topNGroups);
    collectors.add(firstPassGroupingCollector);
  }
  if (includeGroupCount) {
    allGroupsCollector = new TermAllGroupsCollector(field.getName());
    collectors.add(allGroupsCollector);
  }
  return collectors;
}
项目:search-core    文件:SearchGroupsFieldCommand.java   
@Override
public List<Collector> create() throws IOException {
  List<Collector> collectors = new ArrayList<Collector>();
  if (topNGroups > 0) {
    firstPassGroupingCollector = new TermFirstPassGroupingCollector(field.getName(), groupSort, topNGroups);
    collectors.add(firstPassGroupingCollector);
  }
  if (includeGroupCount) {
    allGroupsCollector = new TermAllGroupsCollector(field.getName());
    collectors.add(allGroupsCollector);
  }
  return collectors;
}
项目:read-open-source-code    文件:SearchGroupsFieldCommand.java   
@Override
public List<Collector> create() throws IOException {
  List<Collector> collectors = new ArrayList<Collector>();
  if (topNGroups > 0) {
    firstPassGroupingCollector = new TermFirstPassGroupingCollector(field.getName(), groupSort, topNGroups);
    collectors.add(firstPassGroupingCollector);
  }
  if (includeGroupCount) {
    allGroupsCollector = new TermAllGroupsCollector(field.getName());
    collectors.add(allGroupsCollector);
  }
  return collectors;
}
项目:read-open-source-code    文件:SimpleFacets.java   
/**
 * Returns a grouped facet count for the facet query
 *
 * @see FacetParams#FACET_QUERY
 */
public int getGroupedFacetQueryCount(Query facetQuery) throws IOException {
  String groupField = params.get(GroupParams.GROUP_FIELD);
  if (groupField == null) {
    throw new SolrException (
        SolrException.ErrorCode.BAD_REQUEST,
        "Specify the group.field as parameter or local parameter"
    );
  }

  TermAllGroupsCollector collector = new TermAllGroupsCollector(groupField);
  Filter mainQueryFilter = docs.getTopFilter(); // This returns a filter that only matches documents matching with q param and fq params
  searcher.search(facetQuery, mainQueryFilter, collector);
  return collector.getGroupCount();
}
项目:read-open-source-code    文件:SearchGroupsFieldCommand.java   
@Override
public List<Collector> create() throws IOException {
  List<Collector> collectors = new ArrayList<>();
  if (topNGroups > 0) {
    firstPassGroupingCollector = new TermFirstPassGroupingCollector(field.getName(), groupSort, topNGroups);
    collectors.add(firstPassGroupingCollector);
  }
  if (includeGroupCount) {
    allGroupsCollector = new TermAllGroupsCollector(field.getName());
    collectors.add(allGroupsCollector);
  }
  return collectors;
}
项目:Maskana-Gestor-de-Conocimiento    文件:TestGrouping.java   
private AbstractAllGroupsCollector<?> createAllGroupsCollector(AbstractFirstPassGroupingCollector<?> firstPassGroupingCollector,
                                                            String groupField) {
  if (firstPassGroupingCollector.getClass().isAssignableFrom(TermFirstPassGroupingCollector.class)) {
    return new TermAllGroupsCollector(groupField);
  } else {
    ValueSource vs = new BytesRefFieldSource(groupField);
    return new FunctionAllGroupsCollector(vs, new HashMap<Object, Object>());
  }
}