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


Java Facets.getTopChildren方法代码示例

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


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

示例1: drillDown

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
/** User drills down on 'Publish Date/2010', and we
 *  return facets for 'Author' */
private FacetResult drillDown() throws IOException {
  DirectoryReader indexReader = DirectoryReader.open(indexDir);
  IndexSearcher searcher = new IndexSearcher(indexReader);
  TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);

  // Passing no baseQuery means we drill down on all
  // documents ("browse only"):
  DrillDownQuery q = new DrillDownQuery(config);

  // Now user drills down on Publish Date/2010:
  q.add("Publish Date", "2010");
  FacetsCollector fc = new FacetsCollector();
  FacetsCollector.search(searcher, q, 10, fc);

  // Retrieve results
  Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc);
  FacetResult result = facets.getTopChildren(10, "Author");

  indexReader.close();
  taxoReader.close();
  
  return result;
}
 
开发者ID:skeychen,项目名称:dswork,代码行数:26,代码来源:SimpleFacetsExample.java

示例2: drillDown

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
/** User drills down on 'Publish Year/2010'. */
private FacetResult drillDown() throws IOException {
  DirectoryReader indexReader = DirectoryReader.open(indexDir);
  IndexSearcher searcher = new IndexSearcher(indexReader);
  SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(indexReader);

  // Now user drills down on Publish Year/2010:
  DrillDownQuery q = new DrillDownQuery(config);
  q.add("Publish Year", "2010");
  FacetsCollector fc = new FacetsCollector();
  FacetsCollector.search(searcher, q, 10, fc);

  // Retrieve results
  Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
  FacetResult result = facets.getTopChildren(10, "Author");
  indexReader.close();
  
  return result;
}
 
开发者ID:skeychen,项目名称:dswork,代码行数:20,代码来源:SimpleSortedSetFacetsExample.java

示例3: drillDown

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
/** User drills down on 'tags/solr'. */
private FacetResult drillDown() throws IOException {
  DirectoryReader indexReader = DirectoryReader.open(indexDir);
  IndexSearcher searcher = new IndexSearcher(indexReader);
  TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);

  // Passing no baseQuery means we drill down on all
  // documents ("browse only"):
  DrillDownQuery q = new DrillDownQuery(config);

  // Now user drills down on Publish Date/2010:
  q.add("tags", "solr");
  FacetsCollector fc = new FacetsCollector();
  FacetsCollector.search(searcher, q, 10, fc);

  // Retrieve results
  Facets facets = new TaxonomyFacetSumFloatAssociations("$genre", taxoReader, config, fc);
  FacetResult result = facets.getTopChildren(10, "genre");

  indexReader.close();
  taxoReader.close();
  
  return result;
}
 
开发者ID:skeychen,项目名称:dswork,代码行数:25,代码来源:AssociationsFacetsExample.java

示例4: search

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
/** User runs a query and counts facets. */
public FacetResult search() throws IOException {

  // Aggregates the facet counts
  FacetsCollector fc = new FacetsCollector();

  // MatchAllDocsQuery is for "browsing" (counts facets
  // for all non-deleted docs in the index); normally
  // you'd use a "normal" query:
  FacetsCollector.search(searcher, new MatchAllDocsQuery(), 10, fc);

  Facets facets = new LongRangeFacetCounts("timestamp", fc,
                                           PAST_HOUR,
                                           PAST_SIX_HOURS,
                                           PAST_DAY);
  return facets.getTopChildren(10, "timestamp");
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:RangeFacetsExample.java

示例5: search

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
/** User runs a query and counts facets. */
public FacetResult search() throws IOException {

  FacetsCollector fc = new FacetsCollector();

  searcher.search(new MatchAllDocsQuery(), fc);

  Facets facets = new DoubleRangeFacetCounts("field", getDistanceValueSource(), fc,
                                             getBoundingBoxFilter(ORIGIN_LATITUDE, ORIGIN_LONGITUDE, 10.0),
                                             ONE_KM,
                                             TWO_KM,
                                             FIVE_KM,
                                             TEN_KM);

  return facets.getTopChildren(10, "field");
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:DistanceFacetsExample.java

示例6: drillDown

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
/** User drills down on 'Publish Year/2010'. */
private FacetResult drillDown() throws IOException {
	DirectoryReader indexReader = DirectoryReader.open(directory);
	IndexSearcher searcher = new IndexSearcher(indexReader);
	SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(indexReader);
	
	// Now user drills down on Publish Year/2010:
	DrillDownQuery q = new DrillDownQuery(config);
	q.add("Publish Year", "2010");
	FacetsCollector fc = new FacetsCollector();
	FacetsCollector.search(searcher, q, 10, fc);
	
	// Retrieve results
	Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
	FacetResult result = facets.getTopChildren(10, "Author");
	indexReader.close();
	
	return result;
}
 
开发者ID:lumongo,项目名称:lumongo,代码行数:20,代码来源:FacetStorageTest.java

示例7: getTotalVariationsCountFacet

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
public int getTotalVariationsCountFacet(List<? extends FeatureFile> files, Query query) throws IOException {
    if (CollectionUtils.isEmpty(files)) {
        return 0;
    }

    SimpleFSDirectory[] indexes = fileManager.getIndexesForFiles(files);

    try (MultiReader reader = openMultiReader(indexes)) {
        if (reader.numDocs() == 0) {
            return 0;
        }

        FacetsCollector facetsCollector = new FacetsCollector();
        IndexSearcher searcher = new IndexSearcher(reader);
        searcher.search(query, facetsCollector);

        Facets facets = new SortedSetDocValuesFacetCounts(new DefaultSortedSetDocValuesReaderState(reader,
                                                       FeatureIndexFields.FACET_UID.fieldName), facetsCollector);
        FacetResult res = facets.getTopChildren(reader.numDocs(), FeatureIndexFields.F_UID.getFieldName());
        if (res == null) {
            return 0;
        }

        return res.childCount;
    } finally {
        for (SimpleFSDirectory index : indexes) {
            IOUtils.closeQuietly(index);
        }
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:31,代码来源:FeatureIndexDao.java

示例8: getChromosomeIdsWhereVariationsPresentFacet

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
/**
 * Returns a {@code List} of chromosome IDs for a project, specified by ID, where variations exist and satisfy a
 * specified query
 *
 * @param projectId an ID of a project, which index to query
 * @param query     a query to filter variations
 * @return a {@code List} of chromosome IDs
 * @throws IOException
 */
public List<Long> getChromosomeIdsWhereVariationsPresentFacet(long projectId, Query query) throws IOException {
    List<Long> chromosomeIds = new ArrayList<>();

    try (
        Directory index = fileManager.getIndexForProject(projectId);
        IndexReader reader = DirectoryReader.open(index)
    ) {
        if (reader.numDocs() == 0) {
            return Collections.emptyList();
        }

        FacetsCollector facetsCollector = new FacetsCollector();
        IndexSearcher searcher = new IndexSearcher(reader);
        searcher.search(query, facetsCollector);

        Facets facets = new SortedSetDocValuesFacetCounts(new DefaultSortedSetDocValuesReaderState(reader,
                FeatureIndexFields.FACET_CHR_ID.getFieldName()), facetsCollector);
        FacetResult res = facets.getTopChildren(FACET_LIMIT, FeatureIndexFields.CHR_ID.getFieldName());
        if (res == null) {
            return Collections.emptyList();
        }

        for (LabelAndValue labelAndValue : res.labelValues) {
            chromosomeIds.add(Long.parseLong(labelAndValue.label));
        }
    }

    return chromosomeIds;
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:39,代码来源:FeatureIndexDao.java

示例9: processFacetResults

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
/**
 * Processes the faceting results and adds them to the QueryResults builder.
 *
 * @param indexSearcher the IndexSearcher performing the query
 * @param facetsCollector the FacetsCollector that was used for the search
 * @param facetFields the fields to Facet on
 * @param resultBuilder the QueryResults.Builder
 * @throws IOException if an error occurs performing faceting
 */
protected void processFacetResults(final IndexSearcher indexSearcher, final FacetsCollector facetsCollector, final Set<String> facetFields,
                                   final QueryResults.Builder<QR> resultBuilder) throws IOException {
    if (facetFields == null) {
        return;
    }

    for (String facetField : facetFields) {
        final List<FacetCount> facetResultCounts = new ArrayList<>();

        // TODO this will produce an exception if no documents were indexed with the field to facet on
        // java.lang.IllegalArgumentException: field "foo" was not indexed with SortedSetDocValues
        // at org.apache.lucene.facet.sortedset.DefaultSortedSetDocValuesReaderState.<init>(DefaultSortedSetDocValuesReaderState.java:72)

       if (facetsCollector.getMatchingDocs() != null && facetsCollector.getMatchingDocs().size() > 0) {
            final SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(indexSearcher.getIndexReader(), facetField);
            final Facets facets = new SortedSetDocValuesFacetCounts(state, facetsCollector);

            org.apache.lucene.facet.FacetResult result = facets.getTopChildren(10, facetField);
            for (int i = 0; i < result.childCount; i++) {
                LabelAndValue lv = result.labelValues[i];
                facetResultCounts.add(new FacetCount(lv.label, lv.value.longValue()));
            }
        }
        resultBuilder.addFacetResult(new FacetResult(facetField, facetResultCounts));
    }
}
 
开发者ID:bbende,项目名称:tripod,代码行数:36,代码来源:LuceneService.java

示例10: getTotalVariationsCountFacet

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
public int getTotalVariationsCountFacet(List<? extends FeatureFile> files, Query query) throws IOException {
    if (CollectionUtils.isEmpty(files)) {
        return 0;
    }

    SimpleFSDirectory[] indexes = fileManager.getIndexesForFiles(files);
    long totalIndexSize = getTotalIndexSize(indexes);
    if (totalIndexSize > luceneIndexMaxSizeForGrouping) {
        return 0;
    }

    try (MultiReader reader = openMultiReader(indexes)) {
        if (reader.numDocs() == 0) {
            return 0;
        }

        FacetsCollector facetsCollector = new FacetsCollector();
        IndexSearcher searcher = new IndexSearcher(reader);
        searcher.search(query, facetsCollector);

        Facets facets = new SortedSetDocValuesFacetCounts(new DefaultSortedSetDocValuesReaderState(reader,
                FeatureIndexFields.FACET_UID.fieldName), facetsCollector);
        FacetResult res = facets.getTopChildren(reader.numDocs(), FeatureIndexFields.F_UID.getFieldName());
        if (res == null) {
            return 0;
        }

        return res.childCount;
    } finally {
        for (SimpleFSDirectory index : indexes) {
            IOUtils.closeQuietly(index);
        }
    }
}
 
开发者ID:epam,项目名称:NGB,代码行数:35,代码来源:FeatureIndexDao.java

示例11: getChromosomeIdsWhereVariationsPresentFacet

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
/**
 * Returns a {@code List} of chromosome IDs for a project, specified by ID, where variations exist and satisfy a
 * specified query
 *
 * @param projectId an ID of a project, which index to query
 * @param query     a query to filter variations
 * @return a {@code List} of chromosome IDs
 * @throws IOException
 */
public List<Long> getChromosomeIdsWhereVariationsPresentFacet(long projectId, Query query) throws IOException {
    List<Long> chromosomeIds = new ArrayList<>();

    try (
            Directory index = fileManager.getIndexForProject(projectId);
            IndexReader reader = DirectoryReader.open(index)
    ) {
        if (reader.numDocs() == 0) {
            return Collections.emptyList();
        }

        FacetsCollector facetsCollector = new FacetsCollector();
        IndexSearcher searcher = new IndexSearcher(reader);
        searcher.search(query, facetsCollector);

        Facets facets = new SortedSetDocValuesFacetCounts(new DefaultSortedSetDocValuesReaderState(reader,
                FeatureIndexFields.FACET_CHR_ID.getFieldName()), facetsCollector);
        FacetResult res = facets.getTopChildren(FACET_LIMIT, FeatureIndexFields.CHR_ID.getFieldName());
        if (res == null) {
            return Collections.emptyList();
        }

        for (LabelAndValue labelAndValue : res.labelValues) {
            chromosomeIds.add(Long.parseLong(labelAndValue.label));
        }
    }

    return chromosomeIds;
}
 
开发者ID:epam,项目名称:NGB,代码行数:39,代码来源:FeatureIndexDao.java

示例12: search

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
/** User runs a query and aggregates facets. */
private FacetResult search() throws IOException, ParseException {
  DirectoryReader indexReader = DirectoryReader.open(indexDir);
  IndexSearcher searcher = new IndexSearcher(indexReader);
  TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);

  // Aggregate categories by an expression that combines the document's score
  // and its popularity field
  Expression expr = JavascriptCompiler.compile("_score * sqrt(popularity)");
  SimpleBindings bindings = new SimpleBindings();
  bindings.add(new SortField("_score", SortField.Type.SCORE)); // the score of the document
  bindings.add(new SortField("popularity", SortField.Type.LONG)); // the value of the 'popularity' field

  // Aggregates the facet values
  FacetsCollector fc = new FacetsCollector(true);

  // MatchAllDocsQuery is for "browsing" (counts facets
  // for all non-deleted docs in the index); normally
  // you'd use a "normal" query:
  FacetsCollector.search(searcher, new MatchAllDocsQuery(), 10, fc);

  // Retrieve results
  Facets facets = new TaxonomyFacetSumValueSource(taxoReader, config, fc, expr.getValueSource(bindings));
  FacetResult result = facets.getTopChildren(10, "A");
  
  indexReader.close();
  taxoReader.close();
  
  return result;
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:ExpressionAggregationFacetsExample.java

示例13: testBasicLong

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
public void testBasicLong() throws Exception {
  Directory d = newDirectory();
  RandomIndexWriter w = new RandomIndexWriter(random(), d);
  Document doc = new Document();
  NumericDocValuesField field = new NumericDocValuesField("field", 0L);
  doc.add(field);
  for(long l=0;l<100;l++) {
    field.setLongValue(l);
    w.addDocument(doc);
  }

  // Also add Long.MAX_VALUE
  field.setLongValue(Long.MAX_VALUE);
  w.addDocument(doc);

  IndexReader r = w.getReader();
  w.close();

  FacetsCollector fc = new FacetsCollector();
  IndexSearcher s = newSearcher(r);
  s.search(new MatchAllDocsQuery(), fc);

  Facets facets = new LongRangeFacetCounts("field", fc,
      new LongRange("less than 10", 0L, true, 10L, false),
      new LongRange("less than or equal to 10", 0L, true, 10L, true),
      new LongRange("over 90", 90L, false, 100L, false),
      new LongRange("90 or above", 90L, true, 100L, false),
      new LongRange("over 1000", 1000L, false, Long.MAX_VALUE, true));

  FacetResult result = facets.getTopChildren(10, "field");
  assertEquals("dim=field path=[] value=22 childCount=5\n  less than 10 (10)\n  less than or equal to 10 (11)\n  over 90 (9)\n  90 or above (10)\n  over 1000 (1)\n",
               result.toString());
  
  r.close();
  d.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:37,代码来源:TestRangeFacetCounts.java

示例14: testLongMinMax

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
public void testLongMinMax() throws Exception {

    Directory d = newDirectory();
    RandomIndexWriter w = new RandomIndexWriter(random(), d);
    Document doc = new Document();
    NumericDocValuesField field = new NumericDocValuesField("field", 0L);
    doc.add(field);
    field.setLongValue(Long.MIN_VALUE);
    w.addDocument(doc);
    field.setLongValue(0);
    w.addDocument(doc);
    field.setLongValue(Long.MAX_VALUE);
    w.addDocument(doc);

    IndexReader r = w.getReader();
    w.close();

    FacetsCollector fc = new FacetsCollector();
    IndexSearcher s = newSearcher(r);
    s.search(new MatchAllDocsQuery(), fc);

    Facets facets = new LongRangeFacetCounts("field", fc,
        new LongRange("min", Long.MIN_VALUE, true, Long.MIN_VALUE, true),
        new LongRange("max", Long.MAX_VALUE, true, Long.MAX_VALUE, true),
        new LongRange("all0", Long.MIN_VALUE, true, Long.MAX_VALUE, true),
        new LongRange("all1", Long.MIN_VALUE, false, Long.MAX_VALUE, true),
        new LongRange("all2", Long.MIN_VALUE, true, Long.MAX_VALUE, false),
        new LongRange("all3", Long.MIN_VALUE, false, Long.MAX_VALUE, false));

    FacetResult result = facets.getTopChildren(10, "field");
    assertEquals("dim=field path=[] value=3 childCount=6\n  min (1)\n  max (1)\n  all0 (3)\n  all1 (2)\n  all2 (2)\n  all3 (1)\n",
                 result.toString());
    
    r.close();
    d.close();
  }
 
开发者ID:europeana,项目名称:search,代码行数:37,代码来源:TestRangeFacetCounts.java

示例15: testOverlappedEndStart

import org.apache.lucene.facet.Facets; //导入方法依赖的package包/类
public void testOverlappedEndStart() throws Exception {
  Directory d = newDirectory();
  RandomIndexWriter w = new RandomIndexWriter(random(), d);
  Document doc = new Document();
  NumericDocValuesField field = new NumericDocValuesField("field", 0L);
  doc.add(field);
  for(long l=0;l<100;l++) {
    field.setLongValue(l);
    w.addDocument(doc);
  }
  field.setLongValue(Long.MAX_VALUE);
  w.addDocument(doc);

  IndexReader r = w.getReader();
  w.close();

  FacetsCollector fc = new FacetsCollector();
  IndexSearcher s = newSearcher(r);
  s.search(new MatchAllDocsQuery(), fc);

  Facets facets = new LongRangeFacetCounts("field", fc,
      new LongRange("0-10", 0L, true, 10L, true),
      new LongRange("10-20", 10L, true, 20L, true),
      new LongRange("20-30", 20L, true, 30L, true),
      new LongRange("30-40", 30L, true, 40L, true));
  
  FacetResult result = facets.getTopChildren(10, "field");
  assertEquals("dim=field path=[] value=41 childCount=4\n  0-10 (11)\n  10-20 (11)\n  20-30 (11)\n  30-40 (11)\n",
               result.toString());
  
  r.close();
  d.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:34,代码来源:TestRangeFacetCounts.java


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