本文整理汇总了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();
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}