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


Java LongRange类代码示例

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


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

示例1: search

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

  RangeFacetRequest<LongRange> rangeFacetRequest = new RangeFacetRequest<LongRange>("timestamp",
                                   new LongRange("Past hour", nowSec-3600, true, nowSec, true),
                                   new LongRange("Past six hours", nowSec-6*3600, true, nowSec, true),
                                   new LongRange("Past day", nowSec-24*3600, true, nowSec, true));
  // Aggregatses the facet counts
  FacetsCollector fc = FacetsCollector.create(new RangeAccumulator(rangeFacetRequest));

  // MatchAllDocsQuery is for "browsing" (counts facets
  // for all non-deleted docs in the index); normally
  // you'd use a "normal" query, and use MultiCollector to
  // wrap collecting the "normal" hits and also facets:
  searcher.search(new MatchAllDocsQuery(), fc);

  // Retrieve results
  return fc.getFacetResults();
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:20,代码来源:RangeFacetsExample.java

示例2: main

import org.apache.lucene.facet.range.LongRange; //导入依赖的package包/类
/** Runs the search and drill-down examples and prints the results. */
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
  RangeFacetsExample example = new RangeFacetsExample();
  example.index();

  System.out.println("Facet counting example:");
  System.out.println("-----------------------");
  List<FacetResult> results = example.search();
  for (FacetResult res : results) {
    System.out.println(res);
  }

  System.out.println("\n");
  System.out.println("Facet drill-down example (timestamp/Past six hours):");
  System.out.println("---------------------------------------------");
  TopDocs hits = example.drillDown((LongRange) ((RangeFacetRequest<LongRange>) results.get(0).getFacetRequest()).ranges[1]);
  System.out.println(hits.totalHits + " totalHits");

  example.close();
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:22,代码来源:RangeFacetsExample.java

示例3: drillDown

import org.apache.lucene.facet.range.LongRange; //导入依赖的package包/类
/** User drills down on the specified range. */
public TopDocs drillDown(LongRange range) throws IOException {

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

  q.add("timestamp", NumericRangeQuery.newLongRange("timestamp", range.min, range.max, range.minInclusive, range.maxInclusive));

  return searcher.search(q, 10);
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:RangeFacetsExample.java

示例4: drillDown

import org.apache.lucene.facet.range.LongRange; //导入依赖的package包/类
/** User drills down on the specified range. */
public TopDocs drillDown(LongRange range) throws IOException {

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

  // Use FieldCacheRangeFilter; this will use
  // NumericDocValues:
  q.add("timestamp", NumericRangeQuery.newLongRange("timestamp", range.min, range.max, range.minInclusive, range.maxInclusive));

  return searcher.search(q, 10);
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:14,代码来源:RangeFacetsExample.java

示例5: testDrillDown

import org.apache.lucene.facet.range.LongRange; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testDrillDown() throws Exception {
  RangeFacetsExample example = new RangeFacetsExample();
  example.index();
  List<FacetResult> facetResults = example.search();
  TopDocs hits = example.drillDown((LongRange) ((RangeFacetRequest<LongRange>) facetResults.get(0).getFacetRequest()).ranges[1]);
  assertEquals(22, hits.totalHits);
  example.close();
}
 
开发者ID:jimaguere,项目名称:Maskana-Gestor-de-Conocimiento,代码行数:11,代码来源:TestRangeFacetsExample.java


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