本文整理汇总了Java中org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState类的典型用法代码示例。如果您正苦于以下问题:Java SortedSetDocValuesReaderState类的具体用法?Java SortedSetDocValuesReaderState怎么用?Java SortedSetDocValuesReaderState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SortedSetDocValuesReaderState类属于org.apache.lucene.facet.sortedset包,在下文中一共展示了SortedSetDocValuesReaderState类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: search
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState; //导入依赖的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;
}
示例2: drillDown
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState; //导入依赖的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;
}
示例3: search
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState; //导入依赖的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;
}
示例4: drillDown
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState; //导入依赖的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;
}
示例5: doSearch
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState; //导入依赖的package包/类
private SearchResults doSearch(SearchQuery query, DirectoryReader reader)
throws IOException, ParseException {
try {
IndexSearcher searcher = new IndexSearcher(reader);
SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(
reader);
FacetsCollector fc = new FacetsCollector();
TopDocs docs = FacetsCollector.search(searcher, makeQuery(query),
reader.numDocs(), fc);
Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
return new LuceneSearchResults(searcher, docs, query.getStart(),
query.getRows(), facets);
} finally {
reader.close();
}
}
示例6: drillDown
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState; //导入依赖的package包/类
/** User drills down on 'Publish Year/2010'. */
private List<FacetResult> drillDown() throws IOException {
DirectoryReader indexReader = DirectoryReader.open(indexDir);
IndexSearcher searcher = new IndexSearcher(indexReader);
SortedSetDocValuesReaderState state = new SortedSetDocValuesReaderState(indexReader);
// Now user drills down on Publish Year/2010:
FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("Author"), 10));
DrillDownQuery q = new DrillDownQuery(fsp.indexingParams, new MatchAllDocsQuery());
q.add(new CategoryPath("Publish Year/2010", '/'));
FacetsCollector fc = FacetsCollector.create(new SortedSetDocValuesAccumulator(state, fsp));
searcher.search(q, fc);
// Retrieve results
List<FacetResult> facetResults = fc.getFacetResults();
indexReader.close();
return facetResults;
}
示例7: processFacetResults
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState; //导入依赖的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));
}
}
示例8: DrillSideways
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState; //导入依赖的package包/类
/** Create a new {@code DrillSideways} instance, where some
* dimensions were indexed with {@link
* SortedSetDocValuesFacetField} and others were indexed
* with {@link FacetField}. */
public DrillSideways(IndexSearcher searcher, FacetsConfig config, TaxonomyReader taxoReader, SortedSetDocValuesReaderState state) {
this.searcher = searcher;
this.config = config;
this.taxoReader = taxoReader;
this.state = state;
}
示例9: search
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState; //导入依赖的package包/类
/** User runs a query and counts facets. */
private List<FacetResult> search() throws IOException {
DirectoryReader indexReader = DirectoryReader.open(directory);
IndexSearcher searcher = new IndexSearcher(indexReader);
SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(indexReader);
// 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);
TotalHitCountCollector collector = new TotalHitCountCollector();
searcher.search(new MatchAllDocsQuery(), MultiCollector.wrap(collector, 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;
}
示例10: search
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState; //导入依赖的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 SortedSetDocValuesReaderState(indexReader);
// Count both "Publish Year" and "Author" dimensions
FacetSearchParams fsp = new FacetSearchParams(
new CountFacetRequest(new CategoryPath("Publish Year"), 10),
new CountFacetRequest(new CategoryPath("Author"), 10));
// Aggregatses the facet counts
FacetsCollector fc = FacetsCollector.create(new SortedSetDocValuesAccumulator(state, fsp));
// 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
List<FacetResult> facetResults = fc.getFacetResults();
indexReader.close();
return facetResults;
}
示例11: create
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState; //导入依赖的package包/类
/**
* Creates a {@link FacetsAccumulator} for the given facet requests. This
* method supports {@link RangeAccumulator} and
* {@link SortedSetDocValuesAccumulator} by dividing the facet requests into
* {@link RangeFacetRequest} and the rest.
* <p>
* If both types of facet requests are used, it returns a
* {@link MultiFacetsAccumulator} and the facet results returned from
* {@link #accumulate(List)} may not be in the same order as the given facet
* requests.
*
* @param fsp
* the search params define the facet requests and the
* {@link FacetIndexingParams}
* @param state
* the {@link SortedSetDocValuesReaderState} needed for accumulating
* the categories
* @param arrays
* the {@link FacetArrays} which the accumulator should use to
* store the categories weights in. Can be {@code null}.
*/
public static FacetsAccumulator create(FacetSearchParams fsp, SortedSetDocValuesReaderState state, FacetArrays arrays) throws IOException {
if (fsp.indexingParams.getPartitionSize() != Integer.MAX_VALUE) {
throw new IllegalArgumentException("only default partition size is supported by this method: " + fsp.indexingParams.getPartitionSize());
}
List<FacetRequest> rangeRequests = new ArrayList<FacetRequest>();
List<FacetRequest> nonRangeRequests = new ArrayList<FacetRequest>();
for (FacetRequest fr : fsp.facetRequests) {
if (fr instanceof RangeFacetRequest) {
rangeRequests.add(fr);
} else {
nonRangeRequests.add(fr);
}
}
if (rangeRequests.isEmpty()) {
return new SortedSetDocValuesAccumulator(state, fsp, arrays);
} else if (nonRangeRequests.isEmpty()) {
return new RangeAccumulator(rangeRequests);
} else {
FacetSearchParams searchParams = new FacetSearchParams(fsp.indexingParams, nonRangeRequests);
FacetsAccumulator accumulator = new SortedSetDocValuesAccumulator(state, searchParams, arrays);
RangeAccumulator rangeAccumulator = new RangeAccumulator(rangeRequests);
return MultiFacetsAccumulator.wrap(accumulator, rangeAccumulator);
}
}
示例12: DrillSideways
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState; //导入依赖的package包/类
/**
* Create a new {@code DrillSideways} instance, assuming the categories were
* indexed with {@link SortedSetDocValuesFacetFields}.
*/
public DrillSideways(IndexSearcher searcher, SortedSetDocValuesReaderState state) {
this.searcher = searcher;
this.taxoReader = null;
this.state = state;
}