本文整理汇总了Java中org.apache.lucene.facet.DrillDownQuery类的典型用法代码示例。如果您正苦于以下问题:Java DrillDownQuery类的具体用法?Java DrillDownQuery怎么用?Java DrillDownQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrillDownQuery类属于org.apache.lucene.facet包,在下文中一共展示了DrillDownQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: drillDown
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的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
示例2: drillSideways
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的package包/类
/** User drills down on 'Publish Date/2010', and we
* return facets for both 'Publish Date' and 'Author',
* using DrillSideways. */
private List<FacetResult> drillSideways() 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");
DrillSideways ds = new DrillSideways(searcher, config, taxoReader);
DrillSidewaysResult result = ds.search(q, 10);
// Retrieve results
List<FacetResult> facets = result.facets.getAllDims(10);
indexReader.close();
taxoReader.close();
return facets;
}
开发者ID:skeychen,项目名称:dswork,代码行数:27,代码来源:SimpleFacetsExample.java
示例3: drillDown
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的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
示例4: drillDown
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的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
示例5: transform
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的package包/类
@Override
public org.apache.lucene.search.Query transform(final Query input) throws QueryTransformException {
try {
org.apache.lucene.search.Query luceneQuery = new QueryParser(defaultField, analyzer).parse(input.getQuery());
if (input.getFilterQueries() == null || facetsConfig == null) {
return luceneQuery;
}
// wrap the original query in a DrillDownQuery
DrillDownQuery drillDownQuery = new DrillDownQuery(facetsConfig, luceneQuery);
// add all the filter queries to the DrillDownQuery
input.getFilterQueries().stream().forEach(fq -> drillDownQuery.add(fq.getField().getName(), fq.getValue()));
return drillDownQuery;
} catch (ParseException e) {
throw new QueryTransformException(e.getMessage(), e);
}
}
开发者ID:bbende,项目名称:tripod,代码行数:21,代码来源:StandardLuceneQueryTransformer.java
示例6: drillDown
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的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
示例7: drillDown
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的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
示例8: call
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的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
示例9: testIntSumAssociationDrillDown
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的package包/类
public void testIntSumAssociationDrillDown() throws Exception {
FacetsCollector fc = new FacetsCollector();
IndexSearcher searcher = newSearcher(reader);
DrillDownQuery q = new DrillDownQuery(config);
q.add("int", "b");
searcher.search(q, fc);
Facets facets = new TaxonomyFacetSumIntAssociations("$facets.int", taxoReader, config, fc);
assertEquals("dim=int path=[] value=-1 childCount=2\n b (150)\n a (100)\n", facets.getTopChildren(10, "int").toString());
assertEquals("Wrong count for category 'a'!", 100, facets.getSpecificValue("int", "a").intValue());
assertEquals("Wrong count for category 'b'!", 150, facets.getSpecificValue("int", "b").intValue());
}
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:TestTaxonomyFacetAssociations.java
示例10: createDrilldownQuery
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的package包/类
public Query createDrilldownQuery(Query luceneQuery, List<String[]> drilldownQueries) throws Exception {
BooleanQuery.Builder q = new BooleanQuery.Builder(); // TODO: disableCoord ??
if (luceneQuery != null) {
q.add(luceneQuery, Occur.MUST);
}
for (int i = 0; i < drilldownQueries.size(); i += 2) {
String field = drilldownQueries.get(i)[0];
String indexFieldName = data.getFacetsConfig().getDimConfig(field).indexFieldName;
q.add(new TermQuery(DrillDownQuery.term(indexFieldName, field, drilldownQueries.get(i + 1))), Occur.MUST);
}
return q.build();
}
开发者ID:seecr,项目名称:meresco-lucene,代码行数:13,代码来源:Lucene.java
示例11: testDrilldownQuery
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的package包/类
@Test
public void testDrilldownQuery() {
JsonObject json = Json.createObjectBuilder()
.add("query", Json.createObjectBuilder()
.add("type", "TermQuery")
.add("term", Json.createObjectBuilder()
.add("field", "dd-field")
.add("path", Json.createArrayBuilder()
.add("value"))
.add("type", "DrillDown")))
.build();
QueryData q = new QueryData(new StringReader(json.toString()), queryConverter);
TermQuery query = new TermQuery(DrillDownQuery.term("$facets", "dd-field", "value"));
assertEquals(query, q.query);
}
开发者ID:seecr,项目名称:meresco-lucene,代码行数:16,代码来源:JsonQueryConverterTest.java
示例12: makeFacetQuery
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的package包/类
private Query makeFacetQuery(List<String> facetIds, Query baseQuery) {
DrillDownQuery query = new DrillDownQuery(new FacetsConfig(), baseQuery);
for (String facetId : facetIds) {
int firstColon = facetId.indexOf(':');
String field = facetId.substring(0, firstColon);
String value = facetId.substring(firstColon + 1);
query.add(field, value);
}
return query;
}
开发者ID:KolonelKustard,项目名称:discodj,代码行数:12,代码来源:LuceneSearchProvider.java
示例13: testBasic
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的package包/类
public void testBasic() throws Exception {
assumeTrue("Test requires SortedSetDV support", defaultCodecSupportsSortedSet());
Directory dir = newDirectory();
FacetsConfig config = new FacetsConfig();
config.setMultiValued("a", true);
RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
Document doc = new Document();
doc.add(new SortedSetDocValuesFacetField("a", "foo"));
doc.add(new SortedSetDocValuesFacetField("a", "bar"));
doc.add(new SortedSetDocValuesFacetField("a", "zoo"));
doc.add(new SortedSetDocValuesFacetField("b", "baz"));
writer.addDocument(config.build(doc));
if (random().nextBoolean()) {
writer.commit();
}
doc = new Document();
doc.add(new SortedSetDocValuesFacetField("a", "foo"));
writer.addDocument(config.build(doc));
// NRT open
IndexSearcher searcher = newSearcher(writer.getReader());
// Per-top-reader state:
SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(searcher.getIndexReader());
FacetsCollector c = new FacetsCollector();
searcher.search(new MatchAllDocsQuery(), c);
SortedSetDocValuesFacetCounts facets = new SortedSetDocValuesFacetCounts(state, c);
assertEquals("dim=a path=[] value=4 childCount=3\n foo (2)\n bar (1)\n zoo (1)\n", facets.getTopChildren(10, "a").toString());
assertEquals("dim=b path=[] value=1 childCount=1\n baz (1)\n", facets.getTopChildren(10, "b").toString());
// DrillDown:
DrillDownQuery q = new DrillDownQuery(config);
q.add("a", "foo");
q.add("b", "baz");
TopDocs hits = searcher.search(q, 1);
assertEquals(1, hits.totalHits);
IOUtils.close(writer, searcher.getIndexReader(), dir);
}
开发者ID:europeana,项目名称:search,代码行数:47,代码来源:TestSortedSetDocValuesFacets.java
示例14: testHugeLabel
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的package包/类
@Test
public void testHugeLabel() throws Exception {
Directory indexDir = newDirectory(), taxoDir = newDirectory();
IndexWriter indexWriter = new IndexWriter(indexDir, newIndexWriterConfig(new MockAnalyzer(random())));
DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir, OpenMode.CREATE, new Cl2oTaxonomyWriterCache(2, 1f, 1));
FacetsConfig config = new FacetsConfig();
// Add one huge label:
String bigs = null;
int ordinal = -1;
int len = FacetLabel.MAX_CATEGORY_PATH_LENGTH - 4; // for the dimension and separator
bigs = TestUtil.randomSimpleString(random(), len, len);
FacetField ff = new FacetField("dim", bigs);
FacetLabel cp = new FacetLabel("dim", bigs);
ordinal = taxoWriter.addCategory(cp);
Document doc = new Document();
doc.add(ff);
indexWriter.addDocument(config.build(taxoWriter, doc));
// Add tiny ones to cause a re-hash
for (int i = 0; i < 3; i++) {
String s = TestUtil.randomSimpleString(random(), 1, 10);
taxoWriter.addCategory(new FacetLabel("dim", s));
doc = new Document();
doc.add(new FacetField("dim", s));
indexWriter.addDocument(config.build(taxoWriter, doc));
}
// when too large components were allowed to be added, this resulted in a new added category
assertEquals(ordinal, taxoWriter.addCategory(cp));
IOUtils.close(indexWriter, taxoWriter);
DirectoryReader indexReader = DirectoryReader.open(indexDir);
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
IndexSearcher searcher = new IndexSearcher(indexReader);
DrillDownQuery ddq = new DrillDownQuery(new FacetsConfig());
ddq.add("dim", bigs);
assertEquals(1, searcher.search(ddq, 10).totalHits);
IOUtils.close(indexReader, taxoReader, indexDir, taxoDir);
}
开发者ID:europeana,项目名称:search,代码行数:44,代码来源:TestDirectoryTaxonomyWriter.java
示例15: createDrilldownTerm
import org.apache.lucene.facet.DrillDownQuery; //导入依赖的package包/类
public Term createDrilldownTerm(String field, String... path) {
String indexFieldName = facetsConfig.getDimConfig(field).indexFieldName;
return DrillDownQuery.term(indexFieldName, field, path);
}
开发者ID:seecr,项目名称:meresco-lucene,代码行数:5,代码来源:JsonQueryConverter.java
注:本文中的org.apache.lucene.facet.DrillDownQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论