You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2014/01/04 13:33:29 UTC
svn commit: r1555342 [1/3] - in /lucene/dev/branches/branch_4x: ./
dev-tools/ lucene/ lucene/analysis/ lucene/backwards/ lucene/benchmark/
lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/
lucene/benchmark/src/java/org/apache/lucene/b...
Author: mikemccand
Date: Sat Jan 4 12:33:26 2014
New Revision: 1555342
URL: http://svn.apache.org/r1555342
Log:
LUCENE-5371, LUCENE-5339: speed up range faceting from O(N) per hit to O(log(N)) using segment trees; simplify facet APIs
Added:
lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/demo/src/java/org/apache/lucene/demo/facet/DistanceFacetsExample.java
lucene/dev/branches/branch_4x/lucene/demo/src/test/org/apache/lucene/demo/facet/TestDistanceFacetsExample.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/demo/src/test/org/apache/lucene/demo/facet/TestDistanceFacetsExample.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/CachedOrdinalsReader.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/CachedOrdinalsReader.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/DocValuesOrdinalsReader.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/DocValuesOrdinalsReader.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/DrillDownQuery.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/DrillDownQuery.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/DrillSideways.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/DrillSideways.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysCollector.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysCollector.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysQuery.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysQuery.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysScorer.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/DrillSidewaysScorer.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/FacetField.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/FacetField.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/FacetResult.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/FacetResult.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/Facets.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/Facets.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/FacetsCollector.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/FacetsCollector.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java
- copied, changed from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/LabelAndValue.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/LabelAndValue.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/MultiFacets.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/MultiFacets.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/OrdinalsReader.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/OrdinalsReader.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/TopOrdAndFloatQueue.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/TopOrdAndFloatQueue.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/TopOrdAndIntQueue.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/TopOrdAndIntQueue.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/range/
- copied from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/range/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/sortedset/
- copied from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/sortedset/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/AssociationFacetField.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/AssociationFacetField.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FacetLabel.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FacetLabel.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FastTaxonomyFacetCounts.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FastTaxonomyFacetCounts.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FloatAssociationFacetField.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FloatAssociationFacetField.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FloatTaxonomyFacets.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/FloatTaxonomyFacets.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntAssociationFacetField.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntAssociationFacetField.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntTaxonomyFacets.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntTaxonomyFacets.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/LRUHashMap.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/LRUHashMap.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/PrintTaxonomyStats.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/PrintTaxonomyStats.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/SearcherTaxonomyManager.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/SearcherTaxonomyManager.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetCounts.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetCounts.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumFloatAssociations.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumFloatAssociations.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumIntAssociations.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumIntAssociations.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumValueSource.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacetSumValueSource.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacets.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyFacets.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/CategoryPathUtils.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/CategoryPathUtils.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/CharBlockArray.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/CharBlockArray.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/Cl2oTaxonomyWriterCache.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/Cl2oTaxonomyWriterCache.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/CollisionMap.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/CollisionMap.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/CompactLabelToOrdinal.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/CompactLabelToOrdinal.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/LabelToOrdinal.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/LabelToOrdinal.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/LruTaxonomyWriterCache.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/LruTaxonomyWriterCache.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/NameHashIntCacheLRU.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/NameHashIntCacheLRU.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/NameIntCacheLRU.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/NameIntCacheLRU.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/AssertingSubDocsAtOnceCollector.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/AssertingSubDocsAtOnceCollector.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/TestCachedOrdinalsReader.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/TestCachedOrdinalsReader.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/TestDrillDownQuery.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/TestDrillDownQuery.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/TestDrillSideways.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/TestDrillSideways.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/TestFacetsConfig.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/TestFacetsConfig.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/TestMultipleIndexFields.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/TestMultipleIndexFields.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/range/
- copied from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/range/
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/sortedset/
- copied from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/sortedset/
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestFacetLabel.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestFacetLabel.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestLRUHashMap.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestLRUHashMap.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestSearcherTaxonomyManager.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestSearcherTaxonomyManager.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetAssociations.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetAssociations.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts2.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetCounts2.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetSumValueSource.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyFacetSumValueSource.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCharBlockArray.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCharBlockArray.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCompactLabelToOrdinal.java
- copied unchanged from r1555338, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/TestCompactLabelToOrdinal.java
Removed:
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/FacetPackage.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/associations/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/collections/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/complements/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/encoding/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/old/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/params/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/partitions/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/sampling/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/cl2o/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/lru/
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/util/
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/associations/
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/collections/
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/complements/
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/encoding/
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/old/
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/params/
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/sampling/
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestCategoryPath.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/writercache/cl2o/
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/util/
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/dev-tools/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/BUILD.txt (props changed)
lucene/dev/branches/branch_4x/lucene/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/lucene/JRE_VERSION_MIGRATION.txt (props changed)
lucene/dev/branches/branch_4x/lucene/LICENSE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/MIGRATE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/lucene/README.txt (props changed)
lucene/dev/branches/branch_4x/lucene/SYSTEM_REQUIREMENTS.txt (props changed)
lucene/dev/branches/branch_4x/lucene/analysis/ (props changed)
lucene/dev/branches/branch_4x/lucene/backwards/ (props changed)
lucene/dev/branches/branch_4x/lucene/benchmark/ (props changed)
lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FacetSource.java
lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/RandomFacetSource.java
lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/AddFacetedDocTask.java
lucene/dev/branches/branch_4x/lucene/build.xml (contents, props changed)
lucene/dev/branches/branch_4x/lucene/classification/ (props changed)
lucene/dev/branches/branch_4x/lucene/codecs/ (props changed)
lucene/dev/branches/branch_4x/lucene/common-build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/Field.java
lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
lucene/dev/branches/branch_4x/lucene/demo/ (props changed)
lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/AssociationsFacetsExample.java
lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/ExpressionAggregationFacetsExample.java
lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/MultiCategoryListsFacetsExample.java
lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java
lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleFacetsExample.java
lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleSortedSetFacetsExample.java
lucene/dev/branches/branch_4x/lucene/demo/src/test/org/apache/lucene/demo/facet/TestAssociationsFacetsExample.java
lucene/dev/branches/branch_4x/lucene/demo/src/test/org/apache/lucene/demo/facet/TestExpressionAggregationFacetsExample.java
lucene/dev/branches/branch_4x/lucene/demo/src/test/org/apache/lucene/demo/facet/TestMultiCategoryListsFacetsExample.java
lucene/dev/branches/branch_4x/lucene/demo/src/test/org/apache/lucene/demo/facet/TestRangeFacetsExample.java
lucene/dev/branches/branch_4x/lucene/demo/src/test/org/apache/lucene/demo/facet/TestSimpleFacetsExample.java
lucene/dev/branches/branch_4x/lucene/demo/src/test/org/apache/lucene/demo/facet/TestSimpleSortedSetFacetsExample.java
lucene/dev/branches/branch_4x/lucene/expressions/ (props changed)
lucene/dev/branches/branch_4x/lucene/facet/ (props changed)
lucene/dev/branches/branch_4x/lucene/facet/build.xml
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/package.html
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/ParallelTaxonomyArrays.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyReader.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyWriter.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/Consts.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyWriter.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/writercache/TaxonomyWriterCache.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestCase.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestAddTaxonomy.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestConcurrentFacetedIndexing.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyReader.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestDirectoryTaxonomyWriter.java
lucene/dev/branches/branch_4x/lucene/grouping/ (props changed)
lucene/dev/branches/branch_4x/lucene/highlighter/ (props changed)
lucene/dev/branches/branch_4x/lucene/ivy-settings.xml (props changed)
lucene/dev/branches/branch_4x/lucene/ivy-versions.properties (props changed)
lucene/dev/branches/branch_4x/lucene/join/ (props changed)
lucene/dev/branches/branch_4x/lucene/licenses/ (props changed)
lucene/dev/branches/branch_4x/lucene/memory/ (props changed)
lucene/dev/branches/branch_4x/lucene/misc/ (props changed)
lucene/dev/branches/branch_4x/lucene/module-build.xml (props changed)
lucene/dev/branches/branch_4x/lucene/queries/ (props changed)
lucene/dev/branches/branch_4x/lucene/queryparser/ (props changed)
lucene/dev/branches/branch_4x/lucene/replicator/ (props changed)
lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java
lucene/dev/branches/branch_4x/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyRevisionTest.java
lucene/dev/branches/branch_4x/lucene/sandbox/ (props changed)
lucene/dev/branches/branch_4x/lucene/site/ (props changed)
lucene/dev/branches/branch_4x/lucene/spatial/ (props changed)
lucene/dev/branches/branch_4x/lucene/suggest/ (props changed)
lucene/dev/branches/branch_4x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_4x/lucene/tools/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (props changed)
lucene/dev/branches/branch_4x/solr/LICENSE.txt (props changed)
lucene/dev/branches/branch_4x/solr/NOTICE.txt (props changed)
lucene/dev/branches/branch_4x/solr/README.txt (props changed)
lucene/dev/branches/branch_4x/solr/SYSTEM_REQUIREMENTS.txt (props changed)
lucene/dev/branches/branch_4x/solr/build.xml (props changed)
lucene/dev/branches/branch_4x/solr/cloud-dev/ (props changed)
lucene/dev/branches/branch_4x/solr/common-build.xml (props changed)
lucene/dev/branches/branch_4x/solr/contrib/ (props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/example/ (props changed)
lucene/dev/branches/branch_4x/solr/scripts/ (props changed)
lucene/dev/branches/branch_4x/solr/site/ (props changed)
lucene/dev/branches/branch_4x/solr/solrj/ (props changed)
lucene/dev/branches/branch_4x/solr/test-framework/ (props changed)
lucene/dev/branches/branch_4x/solr/webapp/ (props changed)
Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Sat Jan 4 12:33:26 2014
@@ -21,6 +21,11 @@ New Features
* SOLR-1871: The RangeMapFloatFunction accepts an arbitrary ValueSource
as target and default values. (Chris Harris, shalin)
+* LUCENE-5371: Speed up Lucene range faceting from O(N) per hit to
+ O(log(N)) per hit using segment trees; this only really starts to
+ matter in practice if the number of ranges is over 10 or so. (Mike
+ McCandless)
+
Build
* LUCENE-5217: Maven config: get dependencies from Ant+Ivy config; disable
@@ -62,6 +67,12 @@ Bug fixes
like when index / flush requests happen concurrently to the close or
rollback call. (Simon Willnauer)
+API Changes
+
+* LUCENE-5339: The facet module was simplified/reworked to make the
+ APIs more approachable to new users. (Shai Erera, Gilad Barkai, Rob
+ Muir, Mike McCandless)
+
Changes in Runtime Behavior
* LUCENE-5362: IndexReader and SegmentCoreReaders now throw
Modified: lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FacetSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FacetSource.java?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FacetSource.java (original)
+++ lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FacetSource.java Sat Jan 4 12:33:26 2014
@@ -20,7 +20,8 @@ package org.apache.lucene.benchmark.byTa
import java.io.IOException;
import java.util.List;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.FacetField;
+import org.apache.lucene.facet.FacetsConfig;
/**
* Source items for facets.
@@ -34,7 +35,9 @@ public abstract class FacetSource extend
* account for multi-threading, as multiple threads can call this method
* simultaneously.
*/
- public abstract void getNextFacets(List<CategoryPath> facets) throws NoMoreDataException, IOException;
+ public abstract void getNextFacets(List<FacetField> facets) throws NoMoreDataException, IOException;
+
+ public abstract void configure(FacetsConfig config);
@Override
public void resetInputs() throws IOException {
Modified: lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/RandomFacetSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/RandomFacetSource.java?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/RandomFacetSource.java (original)
+++ lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/RandomFacetSource.java Sat Jan 4 12:33:26 2014
@@ -22,7 +22,8 @@ import java.util.List;
import java.util.Random;
import org.apache.lucene.benchmark.byTask.utils.Config;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.FacetField;
+import org.apache.lucene.facet.FacetsConfig;
/**
* Simple implementation of a random facet source
@@ -31,6 +32,9 @@ import org.apache.lucene.facet.taxonomy.
* <ul>
* <li><b>rand.seed</b> - defines the seed to initialize {@link Random} with
* (default: <b>13</b>).
+ * <li><b>max.doc.facet.dims</b> - Max number of random dimensions to
+ * create (default: <b>5</b>); actual number of dimensions
+ * would be anything between 1 and that number.
* <li><b>max.doc.facets</b> - maximal #facets per doc (default: <b>10</b>).
* Actual number of facets in a certain doc would be anything between 1 and that
* number.
@@ -44,22 +48,38 @@ public class RandomFacetSource extends F
private Random random;
private int maxDocFacets;
private int maxFacetDepth;
+ private int maxDims;
private int maxValue = maxDocFacets * maxFacetDepth;
@Override
- public void getNextFacets(List<CategoryPath> facets) throws NoMoreDataException, IOException {
+ public void getNextFacets(List<FacetField> facets) throws NoMoreDataException, IOException {
facets.clear();
int numFacets = 1 + random.nextInt(maxDocFacets); // at least one facet to each doc
for (int i = 0; i < numFacets; i++) {
- int depth = 1 + random.nextInt(maxFacetDepth); // depth 0 is not useful
- String[] components = new String[depth];
- for (int k = 0; k < depth; k++) {
+ int depth;
+ if (maxFacetDepth == 2) {
+ depth = 2;
+ } else {
+ depth = 2 + random.nextInt(maxFacetDepth-2); // depth < 2 is not useful
+ }
+
+ String dim = Integer.toString(random.nextInt(maxDims));
+ String[] components = new String[depth-1];
+ for (int k = 0; k < depth-1; k++) {
components[k] = Integer.toString(random.nextInt(maxValue));
addItem();
}
- CategoryPath cp = new CategoryPath(components);
- facets.add(cp);
- addBytes(cp.toString().length()); // very rough approximation
+ FacetField ff = new FacetField(dim, components);
+ facets.add(ff);
+ addBytes(ff.toString().length()); // very rough approximation
+ }
+ }
+
+ @Override
+ public void configure(FacetsConfig config) {
+ for(int i=0;i<maxDims;i++) {
+ config.setHierarchical(Integer.toString(i), true);
+ config.setMultiValued(Integer.toString(i), true);
}
}
@@ -73,7 +93,11 @@ public class RandomFacetSource extends F
super.setConfig(config);
random = new Random(config.get("rand.seed", 13));
maxDocFacets = config.get("max.doc.facets", 10);
+ maxDims = config.get("max.doc.facets.dims", 5);
maxFacetDepth = config.get("max.facet.depth", 3);
+ if (maxFacetDepth < 2) {
+ throw new IllegalArgumentException("max.facet.depth must be at least 2; got: " + maxFacetDepth);
+ }
maxValue = maxDocFacets * maxFacetDepth;
}
}
Modified: lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/AddFacetedDocTask.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/AddFacetedDocTask.java?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/AddFacetedDocTask.java (original)
+++ lucene/dev/branches/branch_4x/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/AddFacetedDocTask.java Sat Jan 4 12:33:26 2014
@@ -22,8 +22,12 @@ import java.util.List;
import org.apache.lucene.benchmark.byTask.PerfRunData;
import org.apache.lucene.benchmark.byTask.feeds.FacetSource;
-import org.apache.lucene.facet.index.FacetFields;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.facet.FacetField;
+import org.apache.lucene.facet.FacetsConfig;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
+import org.apache.lucene.index.IndexableField;
/**
* Add a faceted document.
@@ -44,8 +48,7 @@ import org.apache.lucene.facet.taxonomy.
*/
public class AddFacetedDocTask extends AddDocTask {
- private final List<CategoryPath> facets = new ArrayList<CategoryPath>();
- private FacetFields facetFields;
+ private FacetsConfig config;
public AddFacetedDocTask(PerfRunData runData) {
super(runData);
@@ -54,19 +57,19 @@ public class AddFacetedDocTask extends A
@Override
public void setup() throws Exception {
super.setup();
- if (facetFields == null) {
+ if (config == null) {
boolean withFacets = getRunData().getConfig().get("with.facets", true);
if (withFacets) {
FacetSource facetsSource = getRunData().getFacetSource();
- facetFields = withFacets ? new FacetFields(getRunData().getTaxonomyWriter()) : null;
- facetsSource.getNextFacets(facets);
+ config = new FacetsConfig();
+ facetsSource.configure(config);
}
}
}
@Override
protected String getLogMessage(int recsCount) {
- if (facetFields == null) {
+ if (config == null) {
return super.getLogMessage(recsCount);
}
return super.getLogMessage(recsCount)+ " with facets";
@@ -74,10 +77,14 @@ public class AddFacetedDocTask extends A
@Override
public int doLogic() throws Exception {
- if (facetFields != null) {
- facetFields.addFields(doc, facets);
+ if (config != null) {
+ List<FacetField> facets = new ArrayList<FacetField>();
+ getRunData().getFacetSource().getNextFacets(facets);
+ for(FacetField ff : facets) {
+ ((Document) doc).add(ff);
+ }
+ doc = config.build(getRunData().getTaxonomyWriter(), doc);
}
return super.doLogic();
}
-
}
Modified: lucene/dev/branches/branch_4x/lucene/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/build.xml?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/build.xml (original)
+++ lucene/dev/branches/branch_4x/lucene/build.xml Sat Jan 4 12:33:26 2014
@@ -239,7 +239,7 @@
<!-- core: problems -->
<check-missing-javadocs dir="build/docs/demo" level="method"/>
<check-missing-javadocs dir="build/docs/expressions" level="method"/>
- <!-- facet: problems -->
+ <check-missing-javadocs dir="build/docs/facet" level="method"/>
<!-- grouping: problems -->
<!-- highlighter: problems -->
<check-missing-javadocs dir="build/docs/join" level="method"/>
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/Field.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/Field.java?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/Field.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/document/Field.java Sat Jan 4 12:33:26 2014
@@ -552,7 +552,7 @@ public class Field implements IndexableF
return analyzer.tokenStream(name(), stringValue());
}
- throw new IllegalArgumentException("Field must have either TokenStream, String, Reader or Number value");
+ throw new IllegalArgumentException("Field must have either TokenStream, String, Reader or Number value; got " + this);
}
static final class StringTokenStream extends TokenStream {
Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java Sat Jan 4 12:33:26 2014
@@ -439,7 +439,7 @@ public class IndexSearcher {
limit = 1;
}
if (after != null && after.doc >= limit) {
- throw new IllegalArgumentException("after.doc exceeds the number of documents in that reader: after.doc="
+ throw new IllegalArgumentException("after.doc exceeds the number of documents in the reader: after.doc="
+ after.doc + " limit=" + limit);
}
nDocs = Math.min(nDocs, limit);
Modified: lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/AssociationsFacetsExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/AssociationsFacetsExample.java?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/AssociationsFacetsExample.java (original)
+++ lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/AssociationsFacetsExample.java Sat Jan 4 12:33:26 2014
@@ -1,33 +1,5 @@
package org.apache.lucene.demo.facet;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.facet.associations.AssociationsFacetFields;
-import org.apache.lucene.facet.associations.CategoryAssociation;
-import org.apache.lucene.facet.associations.CategoryAssociationsContainer;
-import org.apache.lucene.facet.associations.CategoryFloatAssociation;
-import org.apache.lucene.facet.associations.CategoryIntAssociation;
-import org.apache.lucene.facet.associations.SumFloatAssociationFacetRequest;
-import org.apache.lucene.facet.associations.SumIntAssociationFacetRequest;
-import org.apache.lucene.facet.index.FacetFields;
-import org.apache.lucene.facet.params.FacetSearchParams;
-import org.apache.lucene.facet.search.FacetResult;
-import org.apache.lucene.facet.search.FacetsCollector;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
-import org.apache.lucene.facet.taxonomy.TaxonomyReader;
-import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
-import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
-import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.RAMDirectory;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -45,77 +17,74 @@ import org.apache.lucene.store.RAMDirect
* limitations under the License.
*/
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.facet.FacetResult;
+import org.apache.lucene.facet.Facets;
+import org.apache.lucene.facet.FacetsCollector;
+import org.apache.lucene.facet.FacetsConfig;
+import org.apache.lucene.facet.taxonomy.FloatAssociationFacetField;
+import org.apache.lucene.facet.taxonomy.IntAssociationFacetField;
+import org.apache.lucene.facet.taxonomy.TaxonomyFacetSumFloatAssociations;
+import org.apache.lucene.facet.taxonomy.TaxonomyFacetSumIntAssociations;
+import org.apache.lucene.facet.taxonomy.TaxonomyReader;
+import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
+import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
+
/** Shows example usage of category associations. */
public class AssociationsFacetsExample {
- /**
- * Categories per document, {@link #ASSOCIATIONS} hold the association value
- * for each category.
- */
- public static CategoryPath[][] CATEGORIES = {
- // Doc #1
- { new CategoryPath("tags", "lucene") ,
- new CategoryPath("genre", "computing")
- },
-
- // Doc #2
- { new CategoryPath("tags", "lucene"),
- new CategoryPath("tags", "solr"),
- new CategoryPath("genre", "computing"),
- new CategoryPath("genre", "software")
- }
- };
-
- /** Association values for each category. */
- public static CategoryAssociation[][] ASSOCIATIONS = {
- // Doc #1 associations
- {
- /* 3 occurrences for tag 'lucene' */
- new CategoryIntAssociation(3),
- /* 87% confidence level of genre 'computing' */
- new CategoryFloatAssociation(0.87f)
- },
-
- // Doc #2 associations
- {
- /* 1 occurrence for tag 'lucene' */
- new CategoryIntAssociation(1),
- /* 2 occurrences for tag 'solr' */
- new CategoryIntAssociation(2),
- /* 75% confidence level of genre 'computing' */
- new CategoryFloatAssociation(0.75f),
- /* 34% confidence level of genre 'software' */
- new CategoryFloatAssociation(0.34f),
- }
- };
-
private final Directory indexDir = new RAMDirectory();
private final Directory taxoDir = new RAMDirectory();
+ private final FacetsConfig config;
/** Empty constructor */
- public AssociationsFacetsExample() {}
+ public AssociationsFacetsExample() {
+ config = new FacetsConfig();
+ config.setMultiValued("tags", true);
+ config.setIndexFieldName("tags", "$tags");
+ config.setMultiValued("genre", true);
+ config.setIndexFieldName("genre", "$genre");
+ }
/** Build the example index. */
private void index() throws IOException {
- IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(FacetExamples.EXAMPLES_VER,
- new WhitespaceAnalyzer(FacetExamples.EXAMPLES_VER)));
+ IndexWriterConfig iwc = new IndexWriterConfig(FacetExamples.EXAMPLES_VER,
+ new WhitespaceAnalyzer(FacetExamples.EXAMPLES_VER));
+ IndexWriter indexWriter = new IndexWriter(indexDir, iwc);
// Writes facet ords to a separate directory from the main index
DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
- // Reused across documents, to add the necessary facet fields
- FacetFields facetFields = new AssociationsFacetFields(taxoWriter);
-
- for (int i = 0; i < CATEGORIES.length; i++) {
- Document doc = new Document();
- CategoryAssociationsContainer associations = new CategoryAssociationsContainer();
- for (int j = 0; j < CATEGORIES[i].length; j++) {
- associations.setAssociation(CATEGORIES[i][j], ASSOCIATIONS[i][j]);
- }
- facetFields.addFields(doc, associations);
- indexWriter.addDocument(doc);
- }
-
+ Document doc = new Document();
+ // 3 occurrences for tag 'lucene'
+ doc.add(new IntAssociationFacetField(3, "tags", "lucene"));
+ // 87% confidence level of genre 'computing'
+ doc.add(new FloatAssociationFacetField(0.87f, "genre", "computing"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
+
+ doc = new Document();
+ // 1 occurrence for tag 'lucene'
+ doc.add(new IntAssociationFacetField(1, "tags", "lucene"));
+ // 2 occurrence for tag 'solr'
+ doc.add(new IntAssociationFacetField(2, "tags", "solr"));
+ // 75% confidence level of genre 'computing'
+ doc.add(new FloatAssociationFacetField(0.75f, "genre", "computing"));
+ // 34% confidence level of genre 'software'
+ doc.add(new FloatAssociationFacetField(0.34f, "genre", "software"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
+
indexWriter.close();
taxoWriter.close();
}
@@ -126,25 +95,25 @@ public class AssociationsFacetsExample {
IndexSearcher searcher = new IndexSearcher(indexReader);
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
- CategoryPath tags = new CategoryPath("tags");
- CategoryPath genre = new CategoryPath("genre");
- FacetSearchParams fsp = new FacetSearchParams(new SumIntAssociationFacetRequest(tags, 10),
- new SumFloatAssociationFacetRequest(genre, 10));
- FacetsCollector fc = FacetsCollector.create(fsp, indexReader, taxoReader);
+ 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, and use MultiCollector to
- // wrap collecting the "normal" hits and also facets:
- searcher.search(new MatchAllDocsQuery(), fc);
+ // 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> facetResults = fc.getFacetResults();
-
+ List<FacetResult> results = new ArrayList<FacetResult>();
+ results.add(tags.getTopChildren(10, "tags"));
+ results.add(genre.getTopChildren(10, "genre"));
+
indexReader.close();
taxoReader.close();
- return facetResults;
+ return results;
}
/** Runs summing association example. */
@@ -158,9 +127,7 @@ public class AssociationsFacetsExample {
System.out.println("Sum associations example:");
System.out.println("-------------------------");
List<FacetResult> results = new AssociationsFacetsExample().runSumAssociations();
- for (FacetResult res : results) {
- System.out.println(res);
- }
+ System.out.println("tags: " + results.get(0));
+ System.out.println("genre: " + results.get(1));
}
-
}
Modified: lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/ExpressionAggregationFacetsExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/ExpressionAggregationFacetsExample.java?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/ExpressionAggregationFacetsExample.java (original)
+++ lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/ExpressionAggregationFacetsExample.java Sat Jan 4 12:33:26 2014
@@ -2,8 +2,6 @@ package org.apache.lucene.demo.facet;
import java.io.IOException;
import java.text.ParseException;
-import java.util.Collections;
-import java.util.List;
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
import org.apache.lucene.document.Document;
@@ -13,12 +11,12 @@ import org.apache.lucene.document.TextFi
import org.apache.lucene.expressions.Expression;
import org.apache.lucene.expressions.SimpleBindings;
import org.apache.lucene.expressions.js.JavascriptCompiler;
-import org.apache.lucene.facet.index.FacetFields;
-import org.apache.lucene.facet.params.FacetSearchParams;
-import org.apache.lucene.facet.search.FacetResult;
-import org.apache.lucene.facet.search.FacetsCollector;
-import org.apache.lucene.facet.search.SumValueSourceFacetRequest;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.FacetField;
+import org.apache.lucene.facet.FacetResult;
+import org.apache.lucene.facet.Facets;
+import org.apache.lucene.facet.FacetsCollector;
+import org.apache.lucene.facet.FacetsConfig;
+import org.apache.lucene.facet.taxonomy.TaxonomyFacetSumValueSource;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
@@ -53,18 +51,11 @@ public class ExpressionAggregationFacets
private final Directory indexDir = new RAMDirectory();
private final Directory taxoDir = new RAMDirectory();
+ private final FacetsConfig config = new FacetsConfig();
/** Empty constructor */
public ExpressionAggregationFacetsExample() {}
- private void add(IndexWriter indexWriter, FacetFields facetFields, String text, String category, long popularity) throws IOException {
- Document doc = new Document();
- doc.add(new TextField("c", text, Store.NO));
- doc.add(new NumericDocValuesField("popularity", popularity));
- facetFields.addFields(doc, Collections.singletonList(new CategoryPath(category, '/')));
- indexWriter.addDocument(doc);
- }
-
/** Build the example index. */
private void index() throws IOException {
IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(FacetExamples.EXAMPLES_VER,
@@ -73,18 +64,24 @@ public class ExpressionAggregationFacets
// Writes facet ords to a separate directory from the main index
DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
- // Reused across documents, to add the necessary facet fields
- FacetFields facetFields = new FacetFields(taxoWriter);
-
- add(indexWriter, facetFields, "foo bar", "A/B", 5L);
- add(indexWriter, facetFields, "foo foo bar", "A/C", 3L);
+ Document doc = new Document();
+ doc.add(new TextField("c", "foo bar", Store.NO));
+ doc.add(new NumericDocValuesField("popularity", 5L));
+ doc.add(new FacetField("A", "B"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
+
+ doc = new Document();
+ doc.add(new TextField("c", "foo foo bar", Store.NO));
+ doc.add(new NumericDocValuesField("popularity", 3L));
+ doc.add(new FacetField("A", "C"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
indexWriter.close();
taxoWriter.close();
}
/** User runs a query and aggregates facets. */
- private List<FacetResult> search() throws IOException, ParseException {
+ private FacetResult search() throws IOException, ParseException {
DirectoryReader indexReader = DirectoryReader.open(indexDir);
IndexSearcher searcher = new IndexSearcher(indexReader);
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
@@ -96,29 +93,26 @@ public class ExpressionAggregationFacets
bindings.add(new SortField("_score", SortField.Type.SCORE)); // the score of the document
bindings.add(new SortField("popularity", SortField.Type.LONG)); // the value of the 'popularity' field
- FacetSearchParams fsp = new FacetSearchParams(
- new SumValueSourceFacetRequest(new CategoryPath("A"), 10, expr.getValueSource(bindings), true));
-
// Aggregates the facet values
- FacetsCollector fc = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
+ FacetsCollector fc = new FacetsCollector(true);
// 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);
+ // you'd use a "normal" query:
+ FacetsCollector.search(searcher, new MatchAllDocsQuery(), 10, fc);
// Retrieve results
- List<FacetResult> facetResults = fc.getFacetResults();
+ Facets facets = new TaxonomyFacetSumValueSource(taxoReader, config, fc, expr.getValueSource(bindings));
+ FacetResult result = facets.getTopChildren(10, "A");
indexReader.close();
taxoReader.close();
- return facetResults;
+ return result;
}
/** Runs the search example. */
- public List<FacetResult> runSearch() throws IOException, ParseException {
+ public FacetResult runSearch() throws IOException, ParseException {
index();
return search();
}
@@ -127,10 +121,7 @@ public class ExpressionAggregationFacets
public static void main(String[] args) throws Exception {
System.out.println("Facet counting example:");
System.out.println("-----------------------");
- List<FacetResult> results = new ExpressionAggregationFacetsExample().runSearch();
- for (FacetResult res : results) {
- System.out.println(res);
- }
+ FacetResult result = new ExpressionAggregationFacetsExample().runSearch();
+ System.out.println(result);
}
-
}
Modified: lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/MultiCategoryListsFacetsExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/MultiCategoryListsFacetsExample.java?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/MultiCategoryListsFacetsExample.java (original)
+++ lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/MultiCategoryListsFacetsExample.java Sat Jan 4 12:33:26 2014
@@ -1,33 +1,5 @@
package org.apache.lucene.demo.facet;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.facet.index.FacetFields;
-import org.apache.lucene.facet.params.CategoryListParams;
-import org.apache.lucene.facet.params.FacetIndexingParams;
-import org.apache.lucene.facet.params.FacetSearchParams;
-import org.apache.lucene.facet.params.PerDimensionIndexingParams;
-import org.apache.lucene.facet.search.CountFacetRequest;
-import org.apache.lucene.facet.search.FacetResult;
-import org.apache.lucene.facet.search.FacetsCollector;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
-import org.apache.lucene.facet.taxonomy.TaxonomyReader;
-import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
-import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
-import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.RAMDirectory;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -45,31 +17,41 @@ import org.apache.lucene.store.RAMDirect
* limitations under the License.
*/
-/** Demonstrates indexing categories into different category lists. */
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.facet.FacetField;
+import org.apache.lucene.facet.FacetResult;
+import org.apache.lucene.facet.Facets;
+import org.apache.lucene.facet.FacetsCollector;
+import org.apache.lucene.facet.FacetsConfig;
+import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts;
+import org.apache.lucene.facet.taxonomy.TaxonomyReader;
+import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
+import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
+
+/** Demonstrates indexing categories into different indexed fields. */
public class MultiCategoryListsFacetsExample {
- private final FacetIndexingParams indexingParams;
private final Directory indexDir = new RAMDirectory();
private final Directory taxoDir = new RAMDirectory();
+ private final FacetsConfig config = new FacetsConfig();
/** Creates a new instance and populates the catetory list params mapping. */
public MultiCategoryListsFacetsExample() {
- // index all Author facets in one category list and all Publish Date in another.
- Map<CategoryPath,CategoryListParams> categoryListParams = new HashMap<CategoryPath,CategoryListParams>();
- categoryListParams.put(new CategoryPath("Author"), new CategoryListParams("author"));
- categoryListParams.put(new CategoryPath("Publish Date"), new CategoryListParams("pubdate"));
- indexingParams = new PerDimensionIndexingParams(categoryListParams);
- }
-
- private void add(IndexWriter indexWriter, FacetFields facetFields, String ... categoryPaths) throws IOException {
- Document doc = new Document();
-
- List<CategoryPath> paths = new ArrayList<CategoryPath>();
- for (String categoryPath : categoryPaths) {
- paths.add(new CategoryPath(categoryPath, '/'));
- }
- facetFields.addFields(doc, paths);
- indexWriter.addDocument(doc);
+ config.setIndexFieldName("Author", "author");
+ config.setIndexFieldName("Publish Date", "pubdate");
+ config.setHierarchical("Publish Date", true);
}
/** Build the example index. */
@@ -80,14 +62,30 @@ public class MultiCategoryListsFacetsExa
// Writes facet ords to a separate directory from the main index
DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
- // Reused across documents, to add the necessary facet fields
- FacetFields facetFields = new FacetFields(taxoWriter, indexingParams);
-
- add(indexWriter, facetFields, "Author/Bob", "Publish Date/2010/10/15");
- add(indexWriter, facetFields, "Author/Lisa", "Publish Date/2010/10/20");
- add(indexWriter, facetFields, "Author/Lisa", "Publish Date/2012/1/1");
- add(indexWriter, facetFields, "Author/Susan", "Publish Date/2012/1/7");
- add(indexWriter, facetFields, "Author/Frank", "Publish Date/1999/5/5");
+ Document doc = new Document();
+ doc.add(new FacetField("Author", "Bob"));
+ doc.add(new FacetField("Publish Date", "2010", "10", "15"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
+
+ doc = new Document();
+ doc.add(new FacetField("Author", "Lisa"));
+ doc.add(new FacetField("Publish Date", "2010", "10", "20"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
+
+ doc = new Document();
+ doc.add(new FacetField("Author", "Lisa"));
+ doc.add(new FacetField("Publish Date", "2012", "1", "1"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
+
+ doc = new Document();
+ doc.add(new FacetField("Author", "Susan"));
+ doc.add(new FacetField("Publish Date", "2012", "1", "7"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
+
+ doc = new Document();
+ doc.add(new FacetField("Author", "Frank"));
+ doc.add(new FacetField("Publish Date", "1999", "5", "5"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
indexWriter.close();
taxoWriter.close();
@@ -99,27 +97,27 @@ public class MultiCategoryListsFacetsExa
IndexSearcher searcher = new IndexSearcher(indexReader);
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
- // Count both "Publish Date" and "Author" dimensions
- FacetSearchParams fsp = new FacetSearchParams(indexingParams,
- new CountFacetRequest(new CategoryPath("Publish Date"), 10),
- new CountFacetRequest(new CategoryPath("Author"), 10));
-
- // Aggregatses the facet counts
- FacetsCollector fc = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
+ 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, and use MultiCollector to
- // wrap collecting the "normal" hits and also facets:
- searcher.search(new MatchAllDocsQuery(), fc);
+ // you'd use a "normal" query:
+ FacetsCollector.search(searcher, new MatchAllDocsQuery(), 10, fc);
// Retrieve results
- List<FacetResult> facetResults = fc.getFacetResults();
+ 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 facetResults;
+ return results;
}
/** Runs the search example. */
@@ -133,9 +131,7 @@ public class MultiCategoryListsFacetsExa
System.out.println("Facet counting over multiple category lists example:");
System.out.println("-----------------------");
List<FacetResult> results = new MultiCategoryListsFacetsExample().runSearch();
- for (FacetResult res : results) {
- System.out.println(res);
- }
+ System.out.println("Author: " + results.get(0));
+ System.out.println("Publish Date: " + results.get(1));
}
-
}
Modified: lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java (original)
+++ lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/RangeFacetsExample.java Sat Jan 4 12:33:26 2014
@@ -19,20 +19,19 @@ package org.apache.lucene.demo.facet;
import java.io.Closeable;
import java.io.IOException;
-import java.util.List;
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.LongField;
import org.apache.lucene.document.NumericDocValuesField;
-import org.apache.lucene.facet.params.FacetIndexingParams;
+import org.apache.lucene.facet.DrillDownQuery;
+import org.apache.lucene.facet.FacetResult;
+import org.apache.lucene.facet.Facets;
+import org.apache.lucene.facet.FacetsCollector;
+import org.apache.lucene.facet.FacetsConfig;
import org.apache.lucene.facet.range.LongRange;
-import org.apache.lucene.facet.range.RangeAccumulator;
-import org.apache.lucene.facet.range.RangeFacetRequest;
-import org.apache.lucene.facet.search.DrillDownQuery;
-import org.apache.lucene.facet.search.FacetResult;
-import org.apache.lucene.facet.search.FacetsCollector;
+import org.apache.lucene.facet.range.LongRangeFacetCounts;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
@@ -44,6 +43,7 @@ import org.apache.lucene.store.Directory
import org.apache.lucene.store.RAMDirectory;
+
/** Shows simple usage of dynamic range faceting. */
public class RangeFacetsExample implements Closeable {
@@ -51,6 +51,10 @@ public class RangeFacetsExample implemen
private IndexSearcher searcher;
private final long nowSec = System.currentTimeMillis();
+ final LongRange PAST_HOUR = new LongRange("Past hour", nowSec-3600, true, nowSec, true);
+ final LongRange PAST_SIX_HOURS = new LongRange("Past six hours", nowSec-6*3600, true, nowSec, true);
+ final LongRange PAST_DAY = new LongRange("Past day", nowSec-24*3600, true, nowSec, true);
+
/** Empty constructor */
public RangeFacetsExample() {}
@@ -76,24 +80,26 @@ public class RangeFacetsExample implemen
indexWriter.close();
}
+ private FacetsConfig getConfig() {
+ return new FacetsConfig();
+ }
+
/** User runs a query and counts facets. */
- public List<FacetResult> search() throws IOException {
+ public 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));
+ // 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, and use MultiCollector to
- // wrap collecting the "normal" hits and also facets:
- searcher.search(new MatchAllDocsQuery(), fc);
+ // you'd use a "normal" query:
+ FacetsCollector.search(searcher, new MatchAllDocsQuery(), 10, fc);
- // Retrieve results
- return fc.getFacetResults();
+ Facets facets = new LongRangeFacetCounts("timestamp", fc,
+ PAST_HOUR,
+ PAST_SIX_HOURS,
+ PAST_DAY);
+ return facets.getTopChildren(10, "timestamp");
}
/** User drills down on the specified range. */
@@ -101,10 +107,8 @@ public class RangeFacetsExample implemen
// Passing no baseQuery means we drill down on all
// documents ("browse only"):
- DrillDownQuery q = new DrillDownQuery(FacetIndexingParams.DEFAULT);
+ DrillDownQuery q = new DrillDownQuery(getConfig());
- // 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);
@@ -124,15 +128,12 @@ public class RangeFacetsExample implemen
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(example.search());
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]);
+ TopDocs hits = example.drillDown(example.PAST_SIX_HOURS);
System.out.println(hits.totalHits + " totalHits");
example.close();
Modified: lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleFacetsExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleFacetsExample.java?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleFacetsExample.java (original)
+++ lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleFacetsExample.java Sat Jan 4 12:33:26 2014
@@ -1,29 +1,5 @@
package org.apache.lucene.demo.facet;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.facet.index.FacetFields;
-import org.apache.lucene.facet.params.FacetSearchParams;
-import org.apache.lucene.facet.search.CountFacetRequest;
-import org.apache.lucene.facet.search.DrillDownQuery;
-import org.apache.lucene.facet.search.FacetResult;
-import org.apache.lucene.facet.search.FacetsCollector;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
-import org.apache.lucene.facet.taxonomy.TaxonomyReader;
-import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
-import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
-import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.RAMDirectory;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -41,26 +17,42 @@ import org.apache.lucene.store.RAMDirect
* limitations under the License.
*/
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.facet.DrillDownQuery;
+import org.apache.lucene.facet.FacetField;
+import org.apache.lucene.facet.FacetResult;
+import org.apache.lucene.facet.Facets;
+import org.apache.lucene.facet.FacetsCollector;
+import org.apache.lucene.facet.FacetsConfig;
+import org.apache.lucene.facet.taxonomy.FastTaxonomyFacetCounts;
+import org.apache.lucene.facet.taxonomy.TaxonomyReader;
+import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
+import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
+
/** Shows simple usage of faceted indexing and search. */
public class SimpleFacetsExample {
private final Directory indexDir = new RAMDirectory();
private final Directory taxoDir = new RAMDirectory();
+ private final FacetsConfig config = new FacetsConfig();
/** Empty constructor */
- public SimpleFacetsExample() {}
-
- private void add(IndexWriter indexWriter, FacetFields facetFields, String ... categoryPaths) throws IOException {
- Document doc = new Document();
-
- List<CategoryPath> paths = new ArrayList<CategoryPath>();
- for (String categoryPath : categoryPaths) {
- paths.add(new CategoryPath(categoryPath, '/'));
- }
- facetFields.addFields(doc, paths);
- indexWriter.addDocument(doc);
+ public SimpleFacetsExample() {
+ config.setHierarchical("Publish Date", true);
}
-
+
/** Build the example index. */
private void index() throws IOException {
IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(FacetExamples.EXAMPLES_VER,
@@ -69,14 +61,30 @@ public class SimpleFacetsExample {
// Writes facet ords to a separate directory from the main index
DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(taxoDir);
- // Reused across documents, to add the necessary facet fields
- FacetFields facetFields = new FacetFields(taxoWriter);
-
- add(indexWriter, facetFields, "Author/Bob", "Publish Date/2010/10/15");
- add(indexWriter, facetFields, "Author/Lisa", "Publish Date/2010/10/20");
- add(indexWriter, facetFields, "Author/Lisa", "Publish Date/2012/1/1");
- add(indexWriter, facetFields, "Author/Susan", "Publish Date/2012/1/7");
- add(indexWriter, facetFields, "Author/Frank", "Publish Date/1999/5/5");
+ Document doc = new Document();
+ doc.add(new FacetField("Author", "Bob"));
+ doc.add(new FacetField("Publish Date", "2010", "10", "15"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
+
+ doc = new Document();
+ doc.add(new FacetField("Author", "Lisa"));
+ doc.add(new FacetField("Publish Date", "2010", "10", "20"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
+
+ doc = new Document();
+ doc.add(new FacetField("Author", "Lisa"));
+ doc.add(new FacetField("Publish Date", "2012", "1", "1"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
+
+ doc = new Document();
+ doc.add(new FacetField("Author", "Susan"));
+ doc.add(new FacetField("Publish Date", "2012", "1", "7"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
+
+ doc = new Document();
+ doc.add(new FacetField("Author", "Frank"));
+ doc.add(new FacetField("Publish Date", "1999", "5", "5"));
+ indexWriter.addDocument(config.build(taxoWriter, doc));
indexWriter.close();
taxoWriter.close();
@@ -88,52 +96,50 @@ public class SimpleFacetsExample {
IndexSearcher searcher = new IndexSearcher(indexReader);
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
- // Count both "Publish Date" and "Author" dimensions
- FacetSearchParams fsp = new FacetSearchParams(
- new CountFacetRequest(new CategoryPath("Publish Date"), 10),
- new CountFacetRequest(new CategoryPath("Author"), 10));
-
- // Aggregates the facet counts
- FacetsCollector fc = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
+ 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, and use MultiCollector to
- // wrap collecting the "normal" hits and also facets:
- searcher.search(new MatchAllDocsQuery(), fc);
+ // you'd use a "normal" query:
+ FacetsCollector.search(searcher, new MatchAllDocsQuery(), 10, fc);
// Retrieve results
- List<FacetResult> facetResults = fc.getFacetResults();
+ 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 facetResults;
+ return results;
}
/** User drills down on 'Publish Date/2010'. */
- private List<FacetResult> drillDown() throws IOException {
+ private FacetResult drillDown() throws IOException {
DirectoryReader indexReader = DirectoryReader.open(indexDir);
IndexSearcher searcher = new IndexSearcher(indexReader);
TaxonomyReader taxoReader = new DirectoryTaxonomyReader(taxoDir);
- // Now user drills down on Publish Date/2010:
- FacetSearchParams fsp = new FacetSearchParams(new CountFacetRequest(new CategoryPath("Author"), 10));
-
// Passing no baseQuery means we drill down on all
// documents ("browse only"):
- DrillDownQuery q = new DrillDownQuery(fsp.indexingParams);
- q.add(new CategoryPath("Publish Date/2010", '/'));
- FacetsCollector fc = FacetsCollector.create(fsp, searcher.getIndexReader(), taxoReader);
- searcher.search(q, fc);
+ 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
- List<FacetResult> facetResults = fc.getFacetResults();
-
+ Facets facets = new FastTaxonomyFacetCounts(taxoReader, config, fc);
+ FacetResult result = facets.getTopChildren(10, "Author");
+
indexReader.close();
taxoReader.close();
- return facetResults;
+ return result;
}
/** Runs the search example. */
@@ -143,7 +149,7 @@ public class SimpleFacetsExample {
}
/** Runs the drill-down example. */
- public List<FacetResult> runDrillDown() throws IOException {
+ public FacetResult runDrillDown() throws IOException {
index();
return drillDown();
}
@@ -152,18 +158,15 @@ public class SimpleFacetsExample {
public static void main(String[] args) throws Exception {
System.out.println("Facet counting example:");
System.out.println("-----------------------");
- List<FacetResult> results = new SimpleFacetsExample().runSearch();
- for (FacetResult res : results) {
- System.out.println(res);
- }
+ SimpleFacetsExample example = new SimpleFacetsExample();
+ List<FacetResult> results = example.runSearch();
+ System.out.println("Author: " + results.get(0));
+ System.out.println("Publish Date: " + results.get(1));
System.out.println("\n");
System.out.println("Facet drill-down example (Publish Date/2010):");
System.out.println("---------------------------------------------");
- results = new SimpleFacetsExample().runDrillDown();
- for (FacetResult res : results) {
- System.out.println(res);
- }
+ System.out.println("Author: " + example.runDrillDown());
}
}
Modified: lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleSortedSetFacetsExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleSortedSetFacetsExample.java?rev=1555342&r1=1555341&r2=1555342&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleSortedSetFacetsExample.java (original)
+++ lucene/dev/branches/branch_4x/lucene/demo/src/java/org/apache/lucene/demo/facet/SimpleSortedSetFacetsExample.java Sat Jan 4 12:33:26 2014
@@ -23,15 +23,14 @@ import java.util.List;
import org.apache.lucene.analysis.core.WhitespaceAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.facet.params.FacetSearchParams;
-import org.apache.lucene.facet.search.CountFacetRequest;
-import org.apache.lucene.facet.search.DrillDownQuery;
-import org.apache.lucene.facet.search.FacetResult;
-import org.apache.lucene.facet.search.FacetsCollector;
-import org.apache.lucene.facet.sortedset.SortedSetDocValuesAccumulator;
-import org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetFields;
+import org.apache.lucene.facet.DrillDownQuery;
+import org.apache.lucene.facet.FacetResult;
+import org.apache.lucene.facet.Facets;
+import org.apache.lucene.facet.FacetsCollector;
+import org.apache.lucene.facet.FacetsConfig;
+import org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetCounts;
+import org.apache.lucene.facet.sortedset.SortedSetDocValuesFacetField;
import org.apache.lucene.facet.sortedset.SortedSetDocValuesReaderState;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
@@ -41,40 +40,46 @@ import org.apache.lucene.store.Directory
import org.apache.lucene.store.RAMDirectory;
/** Shows simple usage of faceted indexing and search,
- * using {@link SortedSetDocValuesFacetFields} and {@link
- * SortedSetDocValuesAccumulator}. */
+ * using {@link SortedSetDocValuesFacetField} and {@link
+ * SortedSetDocValuesFacetCounts}. */
public class SimpleSortedSetFacetsExample {
private final Directory indexDir = new RAMDirectory();
+ private final FacetsConfig config = new FacetsConfig();
/** Empty constructor */
- public SimpleSortedSetFacetsExample() {}
-
- private void add(IndexWriter indexWriter, SortedSetDocValuesFacetFields facetFields, String ... categoryPaths) throws IOException {
- Document doc = new Document();
-
- List<CategoryPath> paths = new ArrayList<CategoryPath>();
- for (String categoryPath : categoryPaths) {
- paths.add(new CategoryPath(categoryPath, '/'));
- }
- facetFields.addFields(doc, paths);
- indexWriter.addDocument(doc);
+ public SimpleSortedSetFacetsExample() {
}
/** Build the example index. */
private void index() throws IOException {
IndexWriter indexWriter = new IndexWriter(indexDir, new IndexWriterConfig(FacetExamples.EXAMPLES_VER,
new WhitespaceAnalyzer(FacetExamples.EXAMPLES_VER)));
-
- // Reused across documents, to add the necessary facet fields
- SortedSetDocValuesFacetFields facetFields = new SortedSetDocValuesFacetFields();
-
- add(indexWriter, facetFields, "Author/Bob", "Publish Year/2010");
- add(indexWriter, facetFields, "Author/Lisa", "Publish Year/2010");
- add(indexWriter, facetFields, "Author/Lisa", "Publish Year/2012");
- add(indexWriter, facetFields, "Author/Susan", "Publish Year/2012");
- add(indexWriter, facetFields, "Author/Frank", "Publish Year/1999");
+ Document doc = new Document();
+ doc.add(new SortedSetDocValuesFacetField("Author", "Bob"));
+ doc.add(new SortedSetDocValuesFacetField("Publish Year", "2010"));
+ indexWriter.addDocument(config.build(doc));
+
+ doc = new Document();
+ doc.add(new SortedSetDocValuesFacetField("Author", "Lisa"));
+ doc.add(new SortedSetDocValuesFacetField("Publish Year", "2010"));
+ indexWriter.addDocument(config.build(doc));
+
+ doc = new Document();
+ doc.add(new SortedSetDocValuesFacetField("Author", "Lisa"));
+ doc.add(new SortedSetDocValuesFacetField("Publish Year", "2012"));
+ indexWriter.addDocument(config.build(doc));
+
+ doc = new Document();
+ doc.add(new SortedSetDocValuesFacetField("Author", "Susan"));
+ doc.add(new SortedSetDocValuesFacetField("Publish Year", "2012"));
+ indexWriter.addDocument(config.build(doc));
+
+ doc = new Document();
+ doc.add(new SortedSetDocValuesFacetField("Author", "Frank"));
+ doc.add(new SortedSetDocValuesFacetField("Publish Year", "1999"));
+ indexWriter.addDocument(config.build(doc));
indexWriter.close();
}
@@ -85,47 +90,43 @@ public class SimpleSortedSetFacetsExampl
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));
+ 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, and use MultiCollector to
- // wrap collecting the "normal" hits and also facets:
- searcher.search(new MatchAllDocsQuery(), fc);
+ // you'd use a "normal" query:
+ FacetsCollector.search(searcher, new MatchAllDocsQuery(), 10, fc);
// Retrieve results
- List<FacetResult> facetResults = fc.getFacetResults();
-
+ 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 facetResults;
+ return results;
}
/** User drills down on 'Publish Year/2010'. */
- private List<FacetResult> drillDown() throws IOException {
+ private 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);
+ DrillDownQuery q = new DrillDownQuery(config);
+ q.add("Publish Year", "2010");
+ FacetsCollector fc = new FacetsCollector();
+ FacetsCollector.search(searcher, q, 10, fc);
// Retrieve results
- List<FacetResult> facetResults = fc.getFacetResults();
-
+ Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
+ FacetResult result = facets.getTopChildren(10, "Author");
indexReader.close();
- return facetResults;
+ return result;
}
/** Runs the search example. */
@@ -135,7 +136,7 @@ public class SimpleSortedSetFacetsExampl
}
/** Runs the drill-down example. */
- public List<FacetResult> runDrillDown() throws IOException {
+ public FacetResult runDrillDown() throws IOException {
index();
return drillDown();
}
@@ -144,18 +145,14 @@ public class SimpleSortedSetFacetsExampl
public static void main(String[] args) throws Exception {
System.out.println("Facet counting example:");
System.out.println("-----------------------");
- List<FacetResult> results = new SimpleSortedSetFacetsExample().runSearch();
- for (FacetResult res : results) {
- System.out.println(res);
- }
+ SimpleSortedSetFacetsExample example = new SimpleSortedSetFacetsExample();
+ List<FacetResult> results = example.runSearch();
+ System.out.println("Author: " + results.get(0));
+ System.out.println("Publish Year: " + results.get(0));
System.out.println("\n");
System.out.println("Facet drill-down example (Publish Year/2010):");
System.out.println("---------------------------------------------");
- results = new SimpleSortedSetFacetsExample().runDrillDown();
- for (FacetResult res : results) {
- System.out.println(res);
- }
+ System.out.println("Author: " + example.runDrillDown());
}
-
}