• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FacetResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: facetsWithSearch

import org.apache.lucene.facet.FacetResult; //导入依赖的package包/类
/** User runs a query and counts facets. */
private List<FacetResult> facetsWithSearch() throws IOException {
  DirectoryReader indexReader = DirectoryReader.open(indexDir);
  IndexSearcher searcher = new IndexSearcher(indexReader);
  TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);

  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);

  // Retrieve results
  List<FacetResult> results = new ArrayList<FacetResult>();

  // Count both "Publish Date" and "Author" dimensions
  Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc);
  results.add(facets.getTopChildren(10, "Author"));
  results.add(facets.getTopChildren(10, "Publish Date"));
  
  indexReader.close();
  taxoReader.close();
  
  return results;
}
 
开发者ID:skeychen,项目名称:dswork,代码行数:27,代码来源:SimpleFacetsExample.java


示例2: drillDown

import org.apache.lucene.facet.FacetResult; //导入依赖的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


示例3: drillSideways

import org.apache.lucene.facet.FacetResult; //导入依赖的package包/类
/** User drills down on 'Publish Date/2010', and we
 *  return facets for both 'Publish Date' and 'Author',
 *  using DrillSideways. */
private List<FacetResult> drillSideways() 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");

  DrillSideways ds = new DrillSideways(searcher, config, taxoReader);
  DrillSidewaysResult result = ds.search(q, 10);

  // Retrieve results
  List<FacetResult> facets = result.facets.getAllDims(10);

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


示例4: main

import org.apache.lucene.facet.FacetResult; //导入依赖的package包/类
/** Runs the search and drill-down examples and prints the results. */
public static void main(String[] args) throws Exception {
  System.out.println("Facet counting example:");
  System.out.println("-----------------------");
  SimpleFacetsExample example = new SimpleFacetsExample();
  List<FacetResult> results1 = example.runFacetOnly();
  System.out.println("Author: " + results1.get(0));
  System.out.println("Publish Date: " + results1.get(1));
  
  System.out.println("Facet counting example (combined facets and search):");
  System.out.println("-----------------------");
  List<FacetResult> results = example.runSearch();
  System.out.println("Author: " + results.get(0));
  System.out.println("Publish Date: " + results.get(1));
  
  System.out.println("Facet drill-down example (Publish Date/2010):");
  System.out.println("---------------------------------------------");
  System.out.println("Author: " + example.runDrillDown());

  System.out.println("Facet drill-sideways example (Publish Date/2010):");
  System.out.println("---------------------------------------------");
  for(FacetResult result : example.runDrillSideways()) {
    System.out.println(result);
  }
}
 
开发者ID:skeychen,项目名称:dswork,代码行数:26,代码来源:SimpleFacetsExample.java


示例5: search

import org.apache.lucene.facet.FacetResult; //导入依赖的package包/类
/** User runs a query and counts facets. */
private List<FacetResult> search() throws IOException {
  DirectoryReader indexReader = DirectoryReader.open(indexDir);
  IndexSearcher searcher = new IndexSearcher(indexReader);
  SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(indexReader);

  // Aggregatses 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);

  // Retrieve results
  Facets facets = new SortedSetDocValuesFacetCounts(state, fc);

  List<FacetResult> results = new ArrayList<FacetResult>();
  results.add(facets.getTopChildren(10, "Author"));
  results.add(facets.getTopChildren(10, "Publish Year"));
  indexReader.close();
  
  return results;
}
 
开发者ID:skeychen,项目名称:dswork,代码行数:25,代码来源:SimpleSortedSetFacetsExample.java


示例6: drillDown

import org.apache.lucene.facet.FacetResult; //导入依赖的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


示例7: sumAssociations

import org.apache.lucene.facet.FacetResult; //导入依赖的package包/类
/** User runs a query and aggregates facets by summing their association values. */
private List<FacetResult> sumAssociations() throws IOException {
  DirectoryReader indexReader = DirectoryReader.open(indexDir);
  IndexSearcher searcher = new IndexSearcher(indexReader);
  TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
  
  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 tags = new TaxonomyFacetSumIntAssociations("$tags", taxoReader, config, fc);
  Facets genre = new TaxonomyFacetSumFloatAssociations("$genre", taxoReader, config, fc);

  // Retrieve results
  List<FacetResult> results = new ArrayList<FacetResult>();
  results.add(tags.getTopChildren(10, "tags"));
  results.add(genre.getTopChildren(10, "genre"));

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


示例8: drillDown

import org.apache.lucene.facet.FacetResult; //导入依赖的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


示例9: search

import org.apache.lucene.facet.FacetResult; //导入依赖的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


示例10: facetsWithSearch

import org.apache.lucene.facet.FacetResult; //导入依赖的package包/类
/** User runs a query and counts facets. */
private List<FacetResult> facetsWithSearch() throws IOException {
  DirectoryReader indexReader = DirectoryReader.open(indexDir);
  IndexSearcher searcher = new IndexSearcher(indexReader);
  TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);

  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);

  // Retrieve results
  List<FacetResult> results = new ArrayList<>();

  // Count both "Publish Date" and "Author" dimensions
  Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc);
  results.add(facets.getTopChildren(10, "Author"));
  results.add(facets.getTopChildren(10, "Publish Date"));
  
  indexReader.close();
  taxoReader.close();
  
  return results;
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:SimpleFacetsExample.java


示例11: search

import org.apache.lucene.facet.FacetResult; //导入依赖的package包/类
/** User runs a query and counts facets. */
private List<FacetResult> search() throws IOException {
  DirectoryReader indexReader = DirectoryReader.open(indexDir);
  IndexSearcher searcher = new IndexSearcher(indexReader);
  SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(indexReader);

  // Aggregatses 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);

  // Retrieve results
  Facets facets = new SortedSetDocValuesFacetCounts(state, fc);

  List<FacetResult> results = new ArrayList<>();
  results.add(facets.getTopChildren(10, "Author"));
  results.add(facets.getTopChildren(10, "Publish Year"));
  indexReader.close();
  
  return results;
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:SimpleSortedSetFacetsExample.java


示例12: search

import org.apache.lucene.facet.FacetResult; //导入依赖的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


示例13: sumAssociations

import org.apache.lucene.facet.FacetResult; //导入依赖的package包/类
/** User runs a query and aggregates facets by summing their association values. */
private List<FacetResult> sumAssociations() throws IOException {
  DirectoryReader indexReader = DirectoryReader.open(indexDir);
  IndexSearcher searcher = new IndexSearcher(indexReader);
  TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
  
  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 tags = new TaxonomyFacetSumIntAssociations("$tags", taxoReader, config, fc);
  Facets genre = new TaxonomyFacetSumFloatAssociations("$genre", taxoReader, config, fc);

  // Retrieve results
  List<FacetResult> results = new ArrayList<>();
  results.add(tags.getTopChildren(10, "tags"));
  results.add(genre.getTopChildren(10, "genre"));

  indexReader.close();
  taxoReader.close();
  
  return results;
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:AssociationsFacetsExample.java


示例14: getAllDims

import org.apache.lucene.facet.FacetResult; //导入依赖的package包/类
@Override
public List<FacetResult> getAllDims(int topN) throws IOException {
  int ord = children[TaxonomyReader.ROOT_ORDINAL];
  List<FacetResult> results = new ArrayList<>();
  while (ord != TaxonomyReader.INVALID_ORDINAL) {
    String dim = taxoReader.getPath(ord).components[0];
    FacetsConfig.DimConfig dimConfig = config.getDimConfig(dim);
    if (dimConfig.indexFieldName.equals(indexFieldName)) {
      FacetResult result = getTopChildren(topN, dim);
      if (result != null) {
        results.add(result);
      }
    }
    ord = siblings[ord];
  }

  // Sort by highest value, tie break by dim:
  Collections.sort(results, BY_VALUE_THEN_DIM);
  return results;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:TaxonomyFacets.java


示例15: drillDown

import org.apache.lucene.facet.FacetResult; //导入依赖的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


示例16: main

import org.apache.lucene.facet.FacetResult; //导入依赖的package包/类
/** Runs the search and drill-down examples and prints the results. */
public static void main(String[] args) throws Exception {
	init();

	System.out.println("Facet counting example:");
	System.out.println("-----------------------");
	FacetStorageTest example = new FacetStorageTest();
	List<FacetResult> results = example.runSearch();
	System.out.println("Author: " + results.get(0));
	System.out.println("Publish Year: " + results.get(1));
	
	System.out.println("\n");
	System.out.println("Facet drill-down example (Publish Year/2010):");
	System.out.println("---------------------------------------------");
	System.out.println("Author: " + example.runDrillDown());
}
 
开发者ID:lumongo,项目名称:lumongo,代码行数:17,代码来源:FacetStorageTest.java


示例17: getAllDims

import org.apache.lucene.facet.FacetResult; //导入依赖的package包/类
@Override
public List<FacetResult> getAllDims(int topN) throws IOException {
  int ord = children[TaxonomyReader.ROOT_ORDINAL];
  List<FacetResult> results = new ArrayList<FacetResult>();
  while (ord != TaxonomyReader.INVALID_ORDINAL) {
    String dim = taxoReader.getPath(ord).components[0];
    FacetsConfig.DimConfig dimConfig = config.getDimConfig(dim);
    if (dimConfig.indexFieldName.equals(indexFieldName)) {
      FacetResult result = getTopChildren(topN, dim);
      if (result != null) {
        results.add(result);
      }
    }
    ord = siblings[ord];
  }

  // Sort by highest value, tie break by dim:
  Collections.sort(results, BY_VALUE_THEN_DIM);
  return results;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:21,代码来源:TaxonomyFacets.java


示例18: drilldownDataFromFacetResult

import org.apache.lucene.facet.FacetResult; //导入依赖的package包/类
public List<DrilldownData.Term> drilldownDataFromFacetResult(FacetSuperCollector facetCollector, FacetRequest facet, String[] path, boolean hierarchical) throws IOException {
    FacetResult result = facetCollector.getTopChildren(facet.maxTerms == 0 ? Integer.MAX_VALUE : facet.maxTerms, facet.fieldname, path);
    if (result == null)
        return null;
    List<DrilldownData.Term> terms = new ArrayList<>();
    for (LabelAndValue l : result.labelValues) {
        DrilldownData.Term term = new DrilldownData.Term(l.label, l.value.intValue());
        if (hierarchical) {
            String[] newPath = new String[path.length + 1];
            System.arraycopy(path, 0, newPath, 0, path.length);
            newPath[newPath.length - 1] = l.label;
            term.subTerms = drilldownDataFromFacetResult(facetCollector, facet, newPath, hierarchical);
        }
        terms.add(term);
    }
    return terms;
}
 
开发者ID:seecr,项目名称:meresco-lucene,代码行数:18,代码来源:Lucene.java


示例19: getTotalVariationsCountFacet

import org.apache.lucene.facet.FacetResult; //导入依赖的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


示例20: getChromosomeIdsWhereVariationsPresentFacet

import org.apache.lucene.facet.FacetResult; //导入依赖的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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FieldElement类代码示例发布时间:2022-05-22
下一篇:
Java DanmakuUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap