本文整理汇总了Java中org.apache.lucene.facet.Facets类的典型用法代码示例。如果您正苦于以下问题:Java Facets类的具体用法?Java Facets怎么用?Java Facets使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Facets类属于org.apache.lucene.facet包,在下文中一共展示了Facets类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: facetsWithSearch
import org.apache.lucene.facet.Facets; //导入依赖的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.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
示例3: search
import org.apache.lucene.facet.Facets; //导入依赖的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
示例4: 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
示例5: sumAssociations
import org.apache.lucene.facet.Facets; //导入依赖的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
示例6: 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
示例7: 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
示例8: facetsWithSearch
import org.apache.lucene.facet.Facets; //导入依赖的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
示例9: search
import org.apache.lucene.facet.Facets; //导入依赖的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
示例10: 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
示例11: sumAssociations
import org.apache.lucene.facet.Facets; //导入依赖的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
示例12: testChildCount
import org.apache.lucene.facet.Facets; //导入依赖的package包/类
public void testChildCount() throws Exception {
// LUCENE-4885: FacetResult.numValidDescendants was not set properly by FacetsAccumulator
Directory indexDir = newDirectory();
Directory taxoDir = newDirectory();
DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
IndexWriter iw = new IndexWriter(indexDir, newIndexWriterConfig(new MockAnalyzer(random())));
FacetsConfig config = new FacetsConfig();
for (int i = 0; i < 10; i++) {
Document doc = new Document();
doc.add(new FacetField("a", Integer.toString(i)));
iw.addDocument(config.build(taxoWriter, doc));
}
DirectoryReader r = DirectoryReader.open(iw, true);
DirectoryTaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);
FacetsCollector sfc = new FacetsCollector();
newSearcher(r).search(new MatchAllDocsQuery(), sfc);
Facets facets = getTaxonomyFacetCounts(taxoReader, config, sfc);
assertEquals(10, facets.getTopChildren(2, "a").childCount);
IOUtils.close(taxoWriter, iw, taxoReader, taxoDir, r, indexDir);
}
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:TestTaxonomyFacetCounts.java
示例13: testNoScore
import org.apache.lucene.facet.Facets; //导入依赖的package包/类
public void testNoScore() throws Exception {
Directory indexDir = newDirectory();
Directory taxoDir = newDirectory();
DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
IndexWriter iw = new IndexWriter(indexDir, newIndexWriterConfig(new MockAnalyzer(random())));
FacetsConfig config = new FacetsConfig();
for (int i = 0; i < 4; i++) {
Document doc = new Document();
doc.add(new NumericDocValuesField("price", (i+1)));
doc.add(new FacetField("a", Integer.toString(i % 2)));
iw.addDocument(config.build(taxoWriter, doc));
}
DirectoryReader r = DirectoryReader.open(iw, true);
DirectoryTaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoWriter);
FacetsCollector sfc = new FacetsCollector();
newSearcher(r).search(new MatchAllDocsQuery(), sfc);
Facets facets = new TaxonomyFacetSumValueSource(taxoReader, config, sfc, new LongFieldSource("price"));
assertEquals("dim=a path=[] value=10.0 childCount=2\n 1 (6.0)\n 0 (4.0)\n", facets.getTopChildren(10, "a").toString());
IOUtils.close(taxoWriter, iw, taxoReader, taxoDir, r, indexDir);
}
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:TestTaxonomyFacetSumValueSource.java
示例14: 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
示例15: doSearch
import org.apache.lucene.facet.Facets; //导入依赖的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();
}
}
开发者ID:KolonelKustard,项目名称:discodj,代码行数:18,代码来源:LuceneSearchProvider.java
示例16: 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
示例17: 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
示例18: search
import org.apache.lucene.facet.Facets; //导入依赖的package包/类
/** User runs a query and counts facets. */
private List<FacetResult> search() 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 author = new FastTaxonomyFacetCounts("author", taxoReader, config, fc);
results.add(author.getTopChildren(10, "Author"));
Facets pubDate = new FastTaxonomyFacetCounts("pubdate", taxoReader, config, fc);
results.add(pubDate.getTopChildren(10, "Publish Date"));
indexReader.close();
taxoReader.close();
return results;
}
开发者ID:skeychen,项目名称:dswork,代码行数:29,代码来源:MultiCategoryListsFacetsExample.java
示例19: facetsOnly
import org.apache.lucene.facet.Facets; //导入依赖的package包/类
/** User runs a query and counts facets only without collecting the matching documents.*/
private List<FacetResult> facetsOnly() 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:
searcher.search(new MatchAllDocsQuery(), 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,代码行数:28,代码来源:SimpleFacetsExample.java
示例20: parse
import org.apache.lucene.facet.Facets; //导入依赖的package包/类
public LindenResult parse(TopDocs topDocs, TopGroups<TopDocs> topGroupedDocs,
Facets facets, FacetsCollector facetsCollector) throws IOException {
LindenResult result = new LindenResult();
List<LindenHit> lindenHits;
int totalHits = 0;
if (topDocs != null) {
totalHits = topDocs.totalHits;
lindenHits = parseLindenHits(topDocs.scoreDocs);
} else if (topGroupedDocs != null) {
lindenHits = new ArrayList<>();
totalHits = topGroupedDocs.totalHitCount;
for (GroupDocs<TopDocs> group : topGroupedDocs.groups) {
List<LindenHit> groupHits = parseLindenHits(group.scoreDocs);
LindenHit hitGroup = new LindenHit(groupHits.get(0)).setGroupHits(groupHits);
String groupField = request.getGroupParam().getGroupField();
String groupValue = LindenUtil.getFieldStringValue(leaves, group.scoreDocs[0].doc, groupField);
if (!hitGroup.isSetFields()) {
hitGroup.setFields(new HashMap<String, String>());
}
hitGroup.getFields().put(groupField, groupValue);
lindenHits.add(hitGroup);
}
int groupTotal = topGroupedDocs.totalGroupCount == null ? 0 : topGroupedDocs.totalGroupCount;
result.setTotalGroups(groupTotal);
result.setTotalGroupHits(topGroupedDocs.totalGroupedHitCount);
} else {
lindenHits = new ArrayList<>();
}
result.setTotalHits(totalHits);
result.setHits(lindenHits);
parseFacets(result, facets, facetsCollector);
result.setQueryInfo(new QueryInfo().setQuery(query.toString()));
if (filter != null) {
result.getQueryInfo().setFilter(filter.toString());
}
if (sort != null) {
result.getQueryInfo().setSort(sort.toString());
}
return result;
}
开发者ID:XiaoMi,项目名称:linden,代码行数:41,代码来源:LindenResultParser.java
注:本文中的org.apache.lucene.facet.Facets类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论