本文整理汇总了Java中org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts类的典型用法代码示例。如果您正苦于以下问题:Java FastTaxonomyFacetCounts类的具体用法?Java FastTaxonomyFacetCounts怎么用?Java FastTaxonomyFacetCounts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FastTaxonomyFacetCounts类属于org.apache.lucene.facet.taxonomy包,在下文中一共展示了FastTaxonomyFacetCounts类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: facetsWithSearch
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的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.taxonomy.FastTaxonomyFacetCounts; //导入依赖的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: facetsWithSearch
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的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
示例4: testFaceting
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的package包/类
@Test
public void testFaceting() throws Exception {
DirectoryTaxonomyWriter tw = new DirectoryTaxonomyWriter(taxonomyDirectory);
FacetsConfig cfg = new FacetsConfig();
Document doc1 = new Document();
Document doc2 = new Document();
Document doc3 = new Document();
doc1.add(new FacetField("category", "c2"));
doc2.add(new FacetField("category", "c2"));
doc3.add(new FacetField("category", "c1"));
index(cfg.build(tw, doc1), cfg.build(tw, doc2), cfg.build(tw, doc3));
tw.close();
DirectoryTaxonomyReader tr = new DirectoryTaxonomyReader(taxonomyDirectory);
FacetsCollector fc = new FacetsCollector();
FacetsCollector.search(openSearcher(), new MatchAllDocsQuery(), 10, fc);
Facets facets = new FastTaxonomyFacetCounts(tr, cfg, fc);
FacetResult category = facets.getTopChildren(10, "category");
assertEquals(2, category.childCount);
}
开发者ID:hibernate,项目名称:lucene-jbossmodules,代码行数:22,代码来源:LuceneModuleIT.java
示例5: facetsWithSearch
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的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:orientechnologies,项目名称:orientdb-lucene,代码行数:27,代码来源:LuceneNativeFacet.java
示例6: drillDown
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的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:orientechnologies,项目名称:orientdb-lucene,代码行数:26,代码来源:LuceneNativeFacet.java
示例7: search
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的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
示例8: facetsOnly
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的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
示例9: commit
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的package包/类
public void commit(Search s, SpimeDB db) {
try {
DirectoryTaxonomyReader taxoReader = db.readTaxonomy();
Facets facets = new FastTaxonomyFacetCounts(taxoReader, db.facetConfig(), this);
s.setFacets(facets.getTopChildren(limit, NObject.TAG));
taxoReader.close();
} catch (IOException e) {
throw new RuntimeException(e);
} //finally {
}
开发者ID:automenta,项目名称:spimedb,代码行数:13,代码来源:CollectFacets.java
示例10: search
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的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<>();
// 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:europeana,项目名称:search,代码行数:29,代码来源:MultiCategoryListsFacetsExample.java
示例11: facetsOnly
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的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(), null /*Filter */, 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,代码行数:28,代码来源:SimpleFacetsExample.java
示例12: call
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的package包/类
@Override
public Boolean call() throws Exception {
if (indexReader == null) {
indexReader = DirectoryReader.open(indexDir);
lastIndexGeneration = indexReader.getIndexCommit().getGeneration();
taxoReader = new DirectoryTaxonomyReader(taxoDir);
} else {
// verify search index
DirectoryReader newReader = DirectoryReader.openIfChanged(indexReader);
assertNotNull("should not have reached here if no changes were made to the index", newReader);
long newGeneration = newReader.getIndexCommit().getGeneration();
assertTrue("expected newer generation; current=" + lastIndexGeneration + " new=" + newGeneration, newGeneration > lastIndexGeneration);
indexReader.close();
indexReader = newReader;
lastIndexGeneration = newGeneration;
TestUtil.checkIndex(indexDir);
// verify taxonomy index
DirectoryTaxonomyReader newTaxoReader = TaxonomyReader.openIfChanged(taxoReader);
if (newTaxoReader != null) {
taxoReader.close();
taxoReader = newTaxoReader;
}
TestUtil.checkIndex(taxoDir);
// verify faceted search
int id = Integer.parseInt(indexReader.getIndexCommit().getUserData().get(VERSION_ID), 16);
IndexSearcher searcher = new IndexSearcher(indexReader);
FacetsCollector fc = new FacetsCollector();
searcher.search(new MatchAllDocsQuery(), fc);
Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc);
assertEquals(1, facets.getSpecificValue("A", Integer.toString(id, 16)).intValue());
DrillDownQuery drillDown = new DrillDownQuery(config);
drillDown.add("A", Integer.toString(id, 16));
TopDocs docs = searcher.search(drillDown, 10);
assertEquals(1, docs.totalHits);
}
return null;
}
开发者ID:europeana,项目名称:search,代码行数:41,代码来源:IndexAndTaxonomyReplicationClientTest.java
示例13: facetsOnly
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的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(), null /*Filter */, 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:orientechnologies,项目名称:orientdb-lucene,代码行数:28,代码来源:LuceneNativeFacet.java
示例14: fetchFacet
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的package包/类
private void fetchFacet() {
if (queryContext.facet) {
FacetsCollector facetsCollector = new FacetsCollector(true);
try {
String[] pathFacet = null;
if (queryContext.isDrillDown()) {
DrillDownQuery drillDownQuery = new DrillDownQuery(queryContext.getFacetConfig(), query);
String[] path = queryContext.getDrillDownQuery().split(":");
pathFacet = path[1].split("/");
drillDownQuery.add(path[0], pathFacet);
FacetsCollector.search(queryContext.searcher, drillDownQuery, PAGE_SIZE, facetsCollector);
} else {
FacetsCollector.search(queryContext.searcher, query, PAGE_SIZE, facetsCollector);
}
Facets facets = new FastTaxonomyFacetCounts(queryContext.reader, queryContext.getFacetConfig(), facetsCollector);
FacetResult facetResult = null;
if (pathFacet != null) {
facetResult = facets.getTopChildren(PAGE_SIZE, queryContext.getFacetField(), pathFacet);
} else {
facetResult = facets.getTopChildren(PAGE_SIZE, queryContext.getFacetField());
}
if (facetResult != null) {
List<ODocument> documents = new ArrayList<ODocument>();
// for (FacetResult facetResult : res) {
ODocument doc = new ODocument();
doc.field("childCount", facetResult.childCount);
doc.field("value", facetResult.value);
doc.field("dim", facetResult.dim);
List<ODocument> labelsAndValue = new ArrayList<ODocument>();
for (LabelAndValue labelValue : facetResult.labelValues) {
ODocument doc1 = new ODocument();
doc1.field("label", labelValue.label);
doc1.field("value", labelValue.value);
labelsAndValue.add(doc1);
}
doc.field("labelsValue", labelsAndValue);
documents.add(doc);
queryContext.context.setVariable("$facet", documents);
}
// }
} catch (IOException e) {
e.printStackTrace();
}
}
}
开发者ID:orientechnologies,项目名称:orientdb-lucene,代码行数:55,代码来源:LuceneResultSet.java
示例15: searchWithFacets
import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts; //导入依赖的package包/类
private void searchWithFacets(FacetRequest facetRequest, Query q, IndexSearcher indexSearcher, TopDocsCollector<?> collector,
SegmentResponse.Builder segmentReponseBuilder) throws Exception {
FacetsCollector facetsCollector = new FacetsCollector();
indexSearcher.search(q, MultiCollector.wrap(collector, facetsCollector));
Facets facets = new FastTaxonomyFacetCounts(taxoReader, facetsConfig, facetsCollector);
for (CountRequest countRequest : facetRequest.getCountRequestList()) {
String label = countRequest.getFacetField().getLabel();
if (!indexConfig.existingFacet(label)) {
throw new Exception(label + " is not defined as a facetable field");
}
if (countRequest.hasSegmentFacets()) {
if (indexConfig.getNumberOfSegments() == 1) {
log.info("Segment facets is ignored with segments of 1 for facet <" + label + "> on index <" + indexName + ">");
}
if (countRequest.getSegmentFacets() < countRequest.getMaxFacets()) {
throw new IllegalArgumentException("Segment facets must be greater than or equal to max facets");
}
}
int numOfFacets;
if (indexConfig.getNumberOfSegments() > 1) {
if (countRequest.getSegmentFacets() != 0) {
numOfFacets = countRequest.getSegmentFacets();
}
else {
numOfFacets = countRequest.getMaxFacets() * 8;
}
}
else {
numOfFacets = countRequest.getMaxFacets();
}
FacetResult facetResult = null;
try {
if (indexConfig.getNumberOfSegments() > 1) {
if (countRequest.hasSegmentFacets() && countRequest.getSegmentFacets() == 0) {
//TODO: this not ideal
numOfFacets = taxoReader.getSize();
}
}
facetResult = facets.getTopChildren(numOfFacets, label);
}
catch (UncheckedExecutionException e) {
Throwable cause = e.getCause();
if (cause.getMessage().contains(" was not indexed with SortedSetDocValues")) {
//this is when no data has been indexing into a facet or facet does not exist
}
else {
throw e;
}
}
FacetGroup.Builder fg = FacetGroup.newBuilder();
fg.setCountRequest(countRequest);
if (facetResult != null) {
for (LabelAndValue subResult : facetResult.labelValues) {
FacetCount.Builder facetCountBuilder = FacetCount.newBuilder();
facetCountBuilder.setCount(subResult.value.longValue());
facetCountBuilder.setFacet(subResult.label);
fg.addFacetCount(facetCountBuilder);
}
}
segmentReponseBuilder.addFacetGroup(fg);
}
}
开发者ID:lumongo,项目名称:lumongo,代码行数:76,代码来源:LumongoSegment.java
注:本文中的org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论