lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject svn commit: r1421262 [1/2] - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/facet/ lucene/facet/src/examples/org/apache/lucene/facet/example/adaptive/ lucene/facet/src/examples/org/apache/lucene/facet/example/association/ lucene/facet/src/example...
Date Thu, 13 Dec 2012 12:45:58 GMT
Author: shaie
Date: Thu Dec 13 12:45:53 2012
New Revision: 1421262

URL: http://svn.apache.org/viewvc?rev=1421262&view=rev
Log:
LUCENE-4621: FacetIndexing/SearchParams house cleaning

Added:
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/params/EnhancementsIndexingParamsTest.java
      - copied unchanged from r1421256, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/enhancements/params/EnhancementsIndexingParamsTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java
      - copied unchanged from r1421256, lucene/dev/trunk/lucene/facet/src/test/org/apache/lucene/facet/index/params/FacetIndexingParamsTest.java
Removed:
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/params/DefaultEnhancementsIndexingParams.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/params/DefaultFacetIndexingParams.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/params/DefaultEnhancementsIndexingParamsTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/params/DefaultFacetIndexingParamsTest.java
Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/lucene/facet/   (props changed)
    lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/adaptive/AdaptiveSearcher.java
    lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationUtils.java
    lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java
    lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java
    lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java
    lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/EnhancementsDocumentBuilder.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/params/EnhancementsIndexingParams.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/CategoryDocumentBuilder.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/OrdinalMappingAtomicReader.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/OrdinalPolicy.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/params/FacetIndexingParams.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/params/PerDimensionIndexingParams.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/streaming/CategoryParentsStream.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/StandardFacetsAccumulator.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TotalFacetCounts.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetSearchParams.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java
    lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/util/PartitionsUtils.java
    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/enhancements/CategoryEnhancementDummy1.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy2.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy3.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/TwoEnhancementsTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/association/CustomAssociationPropertyTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/CategoryContainerTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/DummyProperty.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/FacetsPayloadProcessorProviderTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/attributes/CategoryAttributeImplTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/params/PerDimensionIndexingParamsTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/streaming/CategoryParentsStreamTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/streaming/CategoryTokenizerTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/BaseTestTopK.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/DrillDownTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestCategoryListCache.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCounts.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/association/AssociationsFacetRequestTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/params/FacetSearchParamsTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/params/MultiIteratorsPerCLParamsTest.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/OversampleWithDepthTest.java

Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Thu Dec 13 12:45:53 2012
@@ -75,6 +75,12 @@ Changes in backwards compatibility polic
   FacetArrays no longer takes those allocators; if you need to reuse the arrays,
   you should use ReusingFacetArrays. (Shai Erera, Gilad Barkai)
 
+* LUCENE-4621: FacetIndexingParams is now a concrete class (instead of DefaultFIP).
+  Also, the entire IndexingParams chain is now immutable. If you need to override
+  a setting, you should extend the relevant class.
+  Additionally, FacetSearchParams is now immutable, and requires all FacetRequests
+  to speified at initialization time. (Shai Erera)
+  
 New Features
 
 * LUCENE-4226: New experimental StoredFieldsFormat that compresses chunks of

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/adaptive/AdaptiveSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/adaptive/AdaptiveSearcher.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/adaptive/AdaptiveSearcher.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/adaptive/AdaptiveSearcher.java Thu Dec 13 12:45:53 2012
@@ -2,16 +2,6 @@ package org.apache.lucene.facet.example.
 
 import java.util.List;
 
-import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopScoreDocCollector;
-import org.apache.lucene.store.Directory;
-
-import org.apache.lucene.search.MultiCollector;
 import org.apache.lucene.facet.example.ExampleUtils;
 import org.apache.lucene.facet.example.simple.SimpleUtils;
 import org.apache.lucene.facet.search.AdaptiveFacetsAccumulator;
@@ -22,6 +12,15 @@ import org.apache.lucene.facet.search.re
 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.index.DirectoryReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MultiCollector;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopScoreDocCollector;
+import org.apache.lucene.store.Directory;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -78,8 +77,8 @@ public class AdaptiveSearcher {
     ScoredDocIdCollector docIdsCollecor = ScoredDocIdCollector.create(indexReader.maxDoc(), false);
     
     // Faceted search parameters indicate which facets are we interested in 
-    FacetSearchParams facetSearchParams = new FacetSearchParams();
-    facetSearchParams.addFacetRequest(new CountFacetRequest(new CategoryPath("root","a"), 10));
+    FacetSearchParams facetSearchParams = new FacetSearchParams(
+        new CountFacetRequest(new CategoryPath("root", "a"), 10));
     
     // search, into both collectors. note: in case only facets accumulation 
     // is required, the topDocCollector part can be totally discarded

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationUtils.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationUtils.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/association/AssociationUtils.java Thu Dec 13 12:45:53 2012
@@ -4,7 +4,7 @@ import org.apache.lucene.facet.enhanceme
 import org.apache.lucene.facet.enhancements.association.AssociationFloatProperty;
 import org.apache.lucene.facet.enhancements.association.AssociationIntProperty;
 import org.apache.lucene.facet.enhancements.association.AssociationProperty;
-import org.apache.lucene.facet.enhancements.params.DefaultEnhancementsIndexingParams;
+import org.apache.lucene.facet.enhancements.params.EnhancementsIndexingParams;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 
 /*
@@ -73,7 +73,7 @@ public class AssociationUtils {
    * Indexing Params: the indexing params to use when dealing with
    * associations.
    */
-  public static final DefaultEnhancementsIndexingParams assocIndexingParams = 
-    new DefaultEnhancementsIndexingParams(new AssociationEnhancement());
+  public static final EnhancementsIndexingParams assocIndexingParams = new EnhancementsIndexingParams(
+      new AssociationEnhancement());
 
 }

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/merge/TaxonomyMergeUtils.java Thu Dec 13 12:45:53 2012
@@ -3,22 +3,20 @@ package org.apache.lucene.facet.example.
 import java.io.IOException;
 import java.util.List;
 
-import org.apache.lucene.index.AtomicReader;
-import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.index.MultiReader;
-import org.apache.lucene.store.Directory;
-
 import org.apache.lucene.facet.example.ExampleUtils;
 import org.apache.lucene.facet.index.OrdinalMappingAtomicReader;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
 import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter.DiskOrdinalMap;
 import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter.MemoryOrdinalMap;
 import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter.OrdinalMap;
+import org.apache.lucene.index.AtomicReader;
+import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig;
+import org.apache.lucene.index.MultiReader;
+import org.apache.lucene.store.Directory;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -88,7 +86,7 @@ public class TaxonomyMergeUtils {
     destTaxWriter.addTaxonomy(srcTaxDir, map);
 
     int ordinalMap[] = map.getMap();
-    FacetIndexingParams params = new DefaultFacetIndexingParams();
+    FacetIndexingParams params = FacetIndexingParams.ALL_PARENTS;
 
     DirectoryReader reader = DirectoryReader.open(srcIndexDir, -1);
     List<AtomicReaderContext> leaves = reader.leaves();

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLIndexer.java Thu Dec 13 12:45:53 2012
@@ -1,7 +1,9 @@
 package org.apache.lucene.facet.example.multiCL;
 
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Random;
 
 import org.apache.lucene.document.Document;
@@ -74,22 +76,18 @@ public class MultiCLIndexer {
       + "reprehenderit qui in ea voluptate velit esse quam nihil molestiae "
       + "consequatur vel illum qui dolorem eum fugiat quo voluptas nulla pariatur";
   // PerDimensionIndexingParams for multiple category lists
-  public static PerDimensionIndexingParams MULTI_IPARAMS = new PerDimensionIndexingParams();
+  public static final PerDimensionIndexingParams MULTI_IPARAMS;
 
   // Initialize PerDimensionIndexingParams
   static {
-    MULTI_IPARAMS.addCategoryListParams(new CategoryPath("0"),
-        new CategoryListParams(new Term("$Digits", "Zero")));
-    MULTI_IPARAMS.addCategoryListParams(new CategoryPath("1"),
-        new CategoryListParams(new Term("$Digits", "One")));
-    MULTI_IPARAMS.addCategoryListParams(new CategoryPath("2"),
-        new CategoryListParams(new Term("$Digits", "Two")));
-    MULTI_IPARAMS.addCategoryListParams(new CategoryPath("3"),
-        new CategoryListParams(new Term("$Digits", "Three")));
-    MULTI_IPARAMS.addCategoryListParams(new CategoryPath("4"),
-        new CategoryListParams(new Term("$Digits", "Four")));
-    MULTI_IPARAMS.addCategoryListParams(new CategoryPath("5"),
-        new CategoryListParams(new Term("$Digits", "Five")));
+    Map<CategoryPath, CategoryListParams> paramsMap = new HashMap<CategoryPath,CategoryListParams>();
+    paramsMap.put(new CategoryPath("0"), new CategoryListParams(new Term("$Digits", "Zero")));
+    paramsMap.put(new CategoryPath("1"), new CategoryListParams(new Term("$Digits", "One")));
+    paramsMap.put(new CategoryPath("2"), new CategoryListParams(new Term("$Digits", "Two")));
+    paramsMap.put(new CategoryPath("3"), new CategoryListParams(new Term("$Digits", "Three")));
+    paramsMap.put(new CategoryPath("4"), new CategoryListParams(new Term("$Digits", "Four")));
+    paramsMap.put(new CategoryPath("5"), new CategoryListParams(new Term("$Digits", "Five")));
+    MULTI_IPARAMS = new PerDimensionIndexingParams(paramsMap);
   }
   
   /**

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/multiCL/MultiCLSearcher.java Thu Dec 13 12:45:53 2012
@@ -1,5 +1,6 @@
 package org.apache.lucene.facet.example.multiCL;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.lucene.index.DirectoryReader;
@@ -17,6 +18,7 @@ import org.apache.lucene.facet.example.s
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.search.FacetsCollector;
 import org.apache.lucene.facet.search.params.CountFacetRequest;
+import org.apache.lucene.facet.search.params.FacetRequest;
 import org.apache.lucene.facet.search.params.FacetSearchParams;
 import org.apache.lucene.facet.search.results.FacetResult;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
@@ -91,17 +93,14 @@ public class MultiCLSearcher {
     Query q = new TermQuery(new Term(SimpleUtils.TEXT, "Quis"));
     ExampleUtils.log("Query: " + q);
 
-    TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10,
-        true);
+    TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10, true);
 
     // Faceted search parameters indicate which facets are we interested in
-    FacetSearchParams facetSearchParams = new FacetSearchParams(iParams);
-    facetSearchParams.addFacetRequest(new CountFacetRequest(
-        new CategoryPath("5"), 10));
-    facetSearchParams.addFacetRequest(new CountFacetRequest(
-        new CategoryPath("5", "5"), 10));
-    facetSearchParams.addFacetRequest(new CountFacetRequest(
-        new CategoryPath("6", "2"), 10));
+    List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
+    facetRequests.add(new CountFacetRequest(new CategoryPath("5"), 10));
+    facetRequests.add(new CountFacetRequest(new CategoryPath("5", "5"), 10));
+    facetRequests.add(new CountFacetRequest(new CategoryPath("6", "2"), 10));
+    FacetSearchParams facetSearchParams = new FacetSearchParams(facetRequests, iParams);
 
     // Facets collector is the simplest interface for faceted search.
     // It provides faceted search functions that are sufficient to many

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java Thu Dec 13 12:45:53 2012
@@ -1,18 +1,10 @@
 package org.apache.lucene.facet.example.simple;
 
+import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopScoreDocCollector;
-
-import org.apache.lucene.search.MultiCollector;
 import org.apache.lucene.facet.example.ExampleUtils;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.search.DrillDown;
 import org.apache.lucene.facet.search.FacetsCollector;
@@ -23,6 +15,13 @@ import org.apache.lucene.facet.search.re
 import org.apache.lucene.facet.search.results.FacetResultNode;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MultiCollector;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopScoreDocCollector;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -101,16 +100,11 @@ public class SimpleSearcher {
     TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(10, true);
 
     if (indexingParams == null) {
-      indexingParams = new DefaultFacetIndexingParams();
+      indexingParams = FacetIndexingParams.ALL_PARENTS;
     }
     
     // Faceted search parameters indicate which facets are we interested in
-    FacetSearchParams facetSearchParams = new FacetSearchParams(indexingParams);
-    
-    // Add the facet requests of interest to the search params
-    for (FacetRequest frq : facetRequests) {
-      facetSearchParams.addFacetRequest(frq);
-    }
+    FacetSearchParams facetSearchParams = new FacetSearchParams(Arrays.asList(facetRequests), indexingParams);
 
     FacetsCollector facetsCollector = new FacetsCollector(facetSearchParams, indexReader, taxoReader);
 
@@ -138,7 +132,7 @@ public class SimpleSearcher {
   public static List<FacetResult> searchWithDrillDown(IndexReader indexReader,
       TaxonomyReader taxoReader) throws Exception {
 
-    final FacetIndexingParams indexingParams = new DefaultFacetIndexingParams();
+    final FacetIndexingParams indexingParams = FacetIndexingParams.ALL_PARENTS;
     
     // base query the user is interested in
     Query baseQuery = new TermQuery(new Term(SimpleUtils.TEXT, "white"));

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/doc-files/userguide.html Thu Dec 13 12:45:53 2012
@@ -538,7 +538,7 @@ parameters it defines, the following two
 forms: category-tokens (for drill-down) and category-list-tokens (for
 accumulation). This parameter allows to specify, for each category, the
 Lucene term used for maintaining the category-list-tokens for that category.
-The default implementation in <code>DefaultFacetIndexingParams</code> maintains
+The default implementation in <code>FacetIndexingParams</code> maintains
 this information for all categories under the same special dedicated term.
 One case where it is needed to maintain two categories in separate category
 lists, is when it is known that at search time it would be required to use
@@ -548,7 +548,7 @@ call.</li>
 for example, the partition size is set to 1000, a distinct sub-term is used for
 maintaining each 1000 categories, e.g. term1 for categories 0 to 999, term2
 for categories 1000 to 1999, etc. The default implementation in
-<code>DefaultFacetIndexingParams</code> maintains category lists in a single
+<code>FacetIndexingParams</code> maintains category lists in a single
 partition, hence it defines the partition size as <code>Integer.MAX_VALUE</code>. The
 importance of this parameter is on allowing to handle very large
 taxonomies without exhausting RAM resources. This is because at facet

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java Thu Dec 13 12:45:53 2012
@@ -121,7 +121,7 @@ public interface CategoryEnhancement {
    *         {@link CategoryParentsStream}, or {@code null} if there is no such
    *         property.
    */
-  Class<? extends CategoryProperty> getRetainableProperty();
+  CategoryProperty getRetainableProperty();
   
   /**
    * Category enhancements must override {@link Object#equals(Object)}, as it is

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/EnhancementsDocumentBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/EnhancementsDocumentBuilder.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/EnhancementsDocumentBuilder.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/EnhancementsDocumentBuilder.java Thu Dec 13 12:45:53 2012
@@ -53,13 +53,12 @@ public class EnhancementsDocumentBuilder
 
   @Override
   protected TokenStream getParentsStream(CategoryAttributesStream categoryAttributesStream) {
-    List<Class<? extends CategoryProperty>> toRetainList = ((EnhancementsIndexingParams) indexingParams)
-        .getRetainableProperties();
+    List<CategoryProperty> toRetainList = ((EnhancementsIndexingParams) indexingParams).getRetainableProperties();
     if (toRetainList != null) {
       CategoryParentsStream categoryParentsStream = new CategoryParentsStream(
           categoryAttributesStream, taxonomyWriter, indexingParams);
-      for (Class<? extends CategoryProperty> toRetain : toRetainList) {
-        categoryParentsStream.addRetainableProperty(toRetain);
+      for (CategoryProperty toRetain : toRetainList) {
+        categoryParentsStream.addRetainableProperty(toRetain.getClass());
       }
       return categoryParentsStream;
     }

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java Thu Dec 13 12:45:53 2012
@@ -152,7 +152,7 @@ public class AssociationEnhancement impl
   }
 
   @Override
-  public Class<? extends CategoryProperty> getRetainableProperty() {
+  public CategoryProperty getRetainableProperty() {
     return null;
   }
 

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/params/EnhancementsIndexingParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/params/EnhancementsIndexingParams.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/params/EnhancementsIndexingParams.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/enhancements/params/EnhancementsIndexingParams.java Thu Dec 13 12:45:53 2012
@@ -1,12 +1,18 @@
 package org.apache.lucene.facet.enhancements.params;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.lucene.facet.enhancements.CategoryEnhancement;
 import org.apache.lucene.facet.enhancements.EnhancementsDocumentBuilder;
 import org.apache.lucene.facet.index.attributes.CategoryProperty;
-import org.apache.lucene.facet.index.params.FacetIndexingParams;
+import org.apache.lucene.facet.index.params.CategoryListParams;
+import org.apache.lucene.facet.index.params.PerDimensionIndexingParams;
 import org.apache.lucene.facet.index.streaming.CategoryParentsStream;
+import org.apache.lucene.facet.taxonomy.CategoryPath;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -26,41 +32,76 @@ import org.apache.lucene.facet.index.str
  */
 
 /**
- * {@link FacetIndexingParams Facet indexing parameters} for defining
- * {@link CategoryEnhancement category enhancements}. It must contain at least
- * one enhancement, otherwise nothing is "enhanced" about it. When there are
- * more than one, the order matters - see {@link #getCategoryEnhancements()}.
+ * A {@link PerDimensionIndexingParams} for defining {@link CategoryEnhancement
+ * category enhancements}. Must contain at least one enhancement, and when there
+ * are more than one, their order matters.
  * 
+ * @see #getCategoryEnhancements()
  * @see EnhancementsDocumentBuilder
+
  * @lucene.experimental
  */
-public interface EnhancementsIndexingParams extends FacetIndexingParams {
+public class EnhancementsIndexingParams extends PerDimensionIndexingParams {
+
+  private final List<CategoryEnhancement> enhancements;
 
   /**
-   * Add {@link CategoryEnhancement}s to the indexing parameters
-   * @param enhancements enhancements to add
+   * Initializes with the given enhancements
+   * 
+   * @throws IllegalArgumentException
+   *           if no enhancements are provided
    */
-  public void addCategoryEnhancements(CategoryEnhancement... enhancements);
+  public EnhancementsIndexingParams(CategoryEnhancement... enhancements) {
+    this(DEFAULT_CATEGORY_LIST_PARAMS, Collections.<CategoryPath,CategoryListParams> emptyMap(), enhancements);
+  }
 
   /**
-   * Get a list of the active category enhancements. If no enhancements exist
-   * return {@code null}. The order of enhancements in the returned list
-   * dictates the order in which the enhancements data appear in the category
-   * tokens payload.
+   * Initializes with the given enhancements and category list params mappings.
    * 
-   * @return A list of the active category enhancements, or {@code null} if
-   *         there are no enhancements.
+   * @see PerDimensionIndexingParams#PerDimensionIndexingParams(Map, CategoryListParams)
+   * @throws IllegalArgumentException
+   *           if no enhancements are provided
    */
-  public List<CategoryEnhancement> getCategoryEnhancements();
+  public EnhancementsIndexingParams(CategoryListParams categoryListParams, 
+      Map<CategoryPath,CategoryListParams> paramsMap, CategoryEnhancement... enhancements) {
+    super(paramsMap, categoryListParams);
+    validateparams(enhancements);
+    this.enhancements = Arrays.asList(enhancements);
+  }
+
+  private void validateparams(CategoryEnhancement... enhancements) {
+    if (enhancements == null || enhancements.length < 1) {
+      throw new IllegalArgumentException("at least one enhancement is required");
+    }
+  }
 
   /**
-   * Get a list of {@link CategoryProperty} classes to be retained when
-   * creating {@link CategoryParentsStream}.
-   * 
-   * @return the list of {@link CategoryProperty} classes to be retained when
-   *         creating {@link CategoryParentsStream}, or {@code null} if there
-   *         are no such properties.
+   * Returns the list of {@link CategoryEnhancement} as were given at
+   * intialization time. You are not expected to modify the list. The order of
+   * the enhancements dictates the order in which they are written in the
+   * document.
+   */
+  public List<CategoryEnhancement> getCategoryEnhancements() {
+    return enhancements;
+  }
+
+  /**
+   * Returns a list of {@link CategoryProperty} which should be retained when
+   * creating {@link CategoryParentsStream}, or {@code null} if there are no
+   * such properties.
    */
-  public List<Class<? extends CategoryProperty>> getRetainableProperties();
+  public List<CategoryProperty> getRetainableProperties() {
+    List<CategoryProperty> props = new ArrayList<CategoryProperty>();
+    for (CategoryEnhancement enhancement : enhancements) {
+      CategoryProperty prop = enhancement.getRetainableProperty();
+      if (prop != null) {
+        props.add(prop);
+      }
+    }
+    if (props.isEmpty()) {
+      return null;
+    }
+    return props;
+  }
 
 }

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/CategoryDocumentBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/CategoryDocumentBuilder.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/CategoryDocumentBuilder.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/CategoryDocumentBuilder.java Thu Dec 13 12:45:53 2012
@@ -12,12 +12,10 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
 import org.apache.lucene.document.TextField;
-
 import org.apache.lucene.facet.index.attributes.CategoryAttribute;
 import org.apache.lucene.facet.index.attributes.CategoryAttributesIterable;
 import org.apache.lucene.facet.index.categorypolicy.OrdinalPolicy;
 import org.apache.lucene.facet.index.categorypolicy.PathPolicy;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.index.streaming.CategoryAttributesStream;
 import org.apache.lucene.facet.index.streaming.CategoryListTokenizer;
@@ -48,7 +46,7 @@ import org.apache.lucene.facet.taxonomy.
  * A utility class which allows attachment of {@link CategoryPath}s or
  * {@link CategoryAttribute}s to a given document using a taxonomy.<br>
  * Construction could be done with either a given {@link FacetIndexingParams} or
- * the default implementation {@link DefaultFacetIndexingParams}.<br>
+ * the default implementation {@link FacetIndexingParams}.<br>
  * A CategoryDocumentBuilder can be reused by repeatedly setting the categories
  * and building the document. Categories are provided either as
  * {@link CategoryAttribute} elements through {@link #setCategories(Iterable)},
@@ -85,18 +83,16 @@ public class CategoryDocumentBuilder {
   protected Map<String, List<CategoryAttribute>> categoriesMap;
 
   /**
-   * Creating a facets document builder with default facet indexing
-   * parameters.<br>
-   * See:
-   * {@link #CategoryDocumentBuilder(TaxonomyWriter, FacetIndexingParams)}
+   * Creating a facets document builder with default facet indexing parameters.
    * 
    * @param taxonomyWriter
-   *            to which new categories will be added, as well as translating
-   *            known categories to ordinals
-   *
+   *          to which new categories will be added, as well as translating
+   *          known categories to ordinals
+   * 
+   * @see #CategoryDocumentBuilder(TaxonomyWriter, FacetIndexingParams)
    */
   public CategoryDocumentBuilder(TaxonomyWriter taxonomyWriter) {
-    this(taxonomyWriter, new DefaultFacetIndexingParams());
+    this(taxonomyWriter, FacetIndexingParams.ALL_PARENTS);
   }
 
   /**

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/OrdinalMappingAtomicReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/OrdinalMappingAtomicReader.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/OrdinalMappingAtomicReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/OrdinalMappingAtomicReader.java Thu Dec 13 12:45:53 2012
@@ -25,7 +25,6 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.lucene.facet.index.params.CategoryListParams;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter.OrdinalMap;
 import org.apache.lucene.index.AtomicReader;
@@ -71,6 +70,7 @@ import org.apache.lucene.util.encoding.I
  * @lucene.experimental
  */
 public class OrdinalMappingAtomicReader extends FilterAtomicReader {
+  
   private final int[] ordinalMap;
   // a little obtuse: but we dont need to create Term objects this way
   private final Map<String,Map<BytesRef,CategoryListParams>> termMap = 
@@ -82,7 +82,7 @@ public class OrdinalMappingAtomicReader 
    * OrdinalMappingAtomicReader(in, ordinalMap, new DefaultFacetIndexingParams())}
    */
   public OrdinalMappingAtomicReader(AtomicReader in, int[] ordinalMap) {
-    this(in, ordinalMap, new DefaultFacetIndexingParams());
+    this(in, ordinalMap, FacetIndexingParams.ALL_PARENTS);
   }
   
   /**

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/OrdinalPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/OrdinalPolicy.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/OrdinalPolicy.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/categorypolicy/OrdinalPolicy.java Thu Dec 13 12:45:53 2012
@@ -2,7 +2,6 @@ package org.apache.lucene.facet.index.ca
 
 import java.io.Serializable;
 
-import org.apache.lucene.facet.index.streaming.CategoryParentsStream;
 import org.apache.lucene.facet.search.FacetsAccumulator;
 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
 import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
@@ -25,11 +24,9 @@ import org.apache.lucene.facet.taxonomy.
  */
 
 /**
- * Filtering category ordinals in {@link CategoryParentsStream}, where a given
- * category ordinal is added to the stream, and than its parents are being added
- * one after the other using {@link TaxonomyWriter#getParent(int)}. <br>
- * That loop should have a stop point - the default approach (excluding the
- * ROOT) is implemented in {@link OrdinalPolicy#ALL_PARENTS}.
+ * A policy for adding category parent ordinals to the list of ordinals that are
+ * encoded for a given document. The default {@link #ALL_PARENTS} policy always
+ * adds all parents, where {@link #NO_PARENTS} never adds any parents.
  * 
  * @lucene.experimental
  */

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/params/FacetIndexingParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/params/FacetIndexingParams.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/params/FacetIndexingParams.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/params/FacetIndexingParams.java Thu Dec 13 12:45:53 2012
@@ -1,9 +1,11 @@
 package org.apache.lucene.facet.index.params;
 
-import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
 
 import org.apache.lucene.facet.index.categorypolicy.OrdinalPolicy;
 import org.apache.lucene.facet.index.categorypolicy.PathPolicy;
+import org.apache.lucene.facet.search.FacetArrays;
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 
 /*
@@ -24,75 +26,202 @@ import org.apache.lucene.facet.taxonomy.
  */
 
 /**
- * Parameters on how facets are to be written to the index. 
- * For example, which fields and terms are used to refer to the indexed posting list.
- * <P>
- * If non-default parameters were used during indexing, the same parameters
- * must also be passed during faceted search. This requirement is analogous
- * to the requirement during search to know which fields were indexed, and which
- * Analyzer was used on the text.
+ * Defines parameters that are needed for facets indexing. Note that this class
+ * does not have any setters. That's because overriding the default parameters
+ * is considered expert. If you wish to override them, simply extend this class
+ * and override the relevant getter.
+ * 
+ * <p>
+ * <b>NOTE:</b> This class is also used during faceted search in order to e.g.
+ * know which field holds the drill-down terms or the fulltree posting.
+ * Therefore this class should be initialized once and you should refrain from
+ * changing it. Also note that if you make any changes to it (e.g. suddenly
+ * deciding that drill-down terms should be read from a different field) and use
+ * it on an existing index, things may not work as expected.
  * 
  * @lucene.experimental
  */
-public interface FacetIndexingParams extends Serializable {
+public class FacetIndexingParams {
+  
+  // the default CLP, can be a singleton
+  protected static final CategoryListParams DEFAULT_CATEGORY_LIST_PARAMS = new CategoryListParams();
 
   /**
-   * The name of the category-list to put this category in, or null if this
-   * category should not be aggregatable.
-   * <P>
-   * By default, all categories are written to the same category list, but
-   * applications which know in advance that in some situations only parts
-   * of the category hierarchy needs to be counted can divide the categories
-   * into two or more different category lists.
-   * <P>
-   * If null is returned for a category, it means that this category should
-   * not appear in any category list, and thus counts for it cannot be
-   * aggregated. This category can still be used for drill-down, even though
-   * the count for it is not known.
+   * A {@link FacetIndexingParams} which fixes {@link OrdinalPolicy} to
+   * {@link OrdinalPolicy#NO_PARENTS}. This is a singleton equivalent to new
+   * {@link #FacetIndexingParams()}.
    */
-  public CategoryListParams getCategoryListParams(CategoryPath category);
-
+  public static final FacetIndexingParams ALL_PARENTS = new FacetIndexingParams();
+  
   /**
-   * Return info about all category lists in the index.
-   * 
-   * @see #getCategoryListParams(CategoryPath)
+   * The default delimiter with which {@link CategoryPath#getComponent(int)
+   * components} are concatenated when written to the index, e.g. as drill-down
+   * terms. If you choose to override it by overiding
+   * {@link #getFacetDelimChar()}, you should make sure that you return a
+   * character that's not found in any path component.
    */
-  public Iterable<CategoryListParams> getAllCategoryListParams();
+  public static final char DEFAULT_FACET_DELIM_CHAR = '\uF749';
+  
+  private final OrdinalPolicy ordinalPolicy = OrdinalPolicy.ALL_PARENTS;
+  private final PathPolicy pathPolicy = PathPolicy.ALL_CATEGORIES;
+  private final int partitionSize = Integer.MAX_VALUE;
 
-  // TODO (Facet): Add special cases of exact/non-exact category term-text
+  protected final CategoryListParams clParams;
 
   /**
-   * Return the drilldown Term-Text which does not need to do any allocations.
-   * The number of chars set is returned.
+   * Initializes new default params. You should use this constructor only if you
+   * intend to override any of the getters, otherwise you can use
+   * {@link #ALL_PARENTS} to save unnecessary object allocations.
+   */
+  public FacetIndexingParams() {
+    this(DEFAULT_CATEGORY_LIST_PARAMS);
+  }
+
+  /** Initializes new params with the given {@link CategoryListParams}. */
+  public FacetIndexingParams(CategoryListParams categoryListParams) {
+    clParams = categoryListParams;
+  }
+
+  /**
+   * The name of the category list to put this category in, or {@code null} if
+   * this category should not be aggregatable.
+   * <p>
+   * By default, all categories are written to the same category list, but
+   * applications which know in advance that in some situations only parts of
+   * the category hierarchy needs to be counted can divide the categories into
+   * two or more different category lists.
    * <p>
-   * Note: Make sure <code>buffer</code> is large enough.
-   * @see CategoryPath#charsNeededForFullPath()
+   * If {@code null} is returned for a category, it means that this category
+   * should not appear in any category list, and thus weights for it cannot be
+   * aggregated. This category can still be used for drill-down, even though the
+   * its weight is unknown.
+   * 
+   * @see PerDimensionIndexingParams
    */
-  public int drillDownTermText(CategoryPath path, char[] buffer);
+  public CategoryListParams getCategoryListParams(CategoryPath category) {
+    return clParams;
+  }
 
   /**
-   * Get the partition size.
-   * Same value should be used during the life time of an index.
-   * At search time this value is compared with actual taxonomy size and their minimum is used.
+   * Copies the text required to execute a drill-down query on the given
+   * category to the given {@code char[]}, and returns the number of characters
+   * that were written.
+   * <p>
+   * <b>NOTE:</b> You should make sure that the {@code char[]} is large enough,
+   * by e.g. calling {@link CategoryPath#charsNeededForFullPath()}.
    */
-  public int getPartitionSize();
+  public int drillDownTermText(CategoryPath path, char[] buffer) {
+    return path.copyToCharArray(buffer, 0, -1, getFacetDelimChar());
+  }
+  
+  /**
+   * Returns the size of a partition. <i>Partitions</i> allow you to divide
+   * (hence, partition) the categories space into small sets to e.g. improve RAM
+   * consumption during faceted search. For instance, {@code partitionSize=100K}
+   * would mean that if your taxonomy index contains 420K categories, they will
+   * be divided into 5 groups and at search time a {@link FacetArrays} will be
+   * allocated at the size of the partition.
+   * 
+   * <p>
+   * This is real advanced setting and should be changed with care. By default,
+   * all categories are put in one partition. You should modify this setting if
+   * you have really large taxonomies (e.g. 1M+ nodes).
+   */
+  public int getPartitionSize() {
+    return partitionSize;
+  }
 
-  /** 
-   * Get the policy for indexing category <b>paths</b>, 
-   * used for deciding how "high" to climb in taxonomy 
-   * from a category when ingesting its category paths. 
+  /**
+   * Returns a list of all {@link CategoryListParams categoryListParams} that
+   * are used for facets indexing.
    */
-  public PathPolicy getPathPolicy();
+  public List<CategoryListParams> getAllCategoryListParams() {
+    return Collections.singletonList(clParams);
+  }
+
+  /**
+   * Returns the {@link OrdinalPolicy} that is used during indexing. By default
+   * returns {@link OrdinalPolicy#ALL_PARENTS} which means that the full
+   * hierarchy will be stored for every document.
+   */
+  public OrdinalPolicy getOrdinalPolicy() {
+    return ordinalPolicy;
+  }
+
+  /**
+   * Returns the {@link PathPolicy} that is used during indexing. By default
+   * returns {@link PathPolicy#ALL_CATEGORIES} which means that the full
+   * hierarchy is added as drill-down terms for every document.
+   */
+  public PathPolicy getPathPolicy() {
+    return pathPolicy;
+  }
+
+  @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    result = prime * result + ((clParams == null) ? 0 : clParams.hashCode());
+    result = prime * result + ((ordinalPolicy == null) ? 0 : ordinalPolicy.hashCode());
+    result = prime * result + partitionSize;
+    result = prime * result + ((pathPolicy == null) ? 0 : pathPolicy.hashCode());
+    
+    for (CategoryListParams clp : getAllCategoryListParams()) {
+      result ^= clp.hashCode();
+    }
+    
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj) {
+      return true;
+    }
+    if (obj == null) {
+      return false;
+    }
+    if (!(obj instanceof FacetIndexingParams)) {
+      return false;
+    }
+    FacetIndexingParams other = (FacetIndexingParams) obj;
+    if (clParams == null) {
+      if (other.clParams != null) {
+        return false;
+      }
+    } else if (!clParams.equals(other.clParams)) {
+      return false;
+    }
+    if (ordinalPolicy == null) {
+      if (other.ordinalPolicy != null) {
+        return false;
+      }
+    } else if (!ordinalPolicy.equals(other.ordinalPolicy)) {
+      return false;
+    }
+    if (partitionSize != other.partitionSize) {
+      return false;
+    }
+    if (pathPolicy == null) {
+      if (other.pathPolicy != null) {
+        return false;
+      }
+    } else if (!pathPolicy.equals(other.pathPolicy)) {
+      return false;
+    }
+    
+    Iterable<CategoryListParams> cLs = getAllCategoryListParams();
+    Iterable<CategoryListParams> otherCLs = other.getAllCategoryListParams();
+    
+    return cLs.equals(otherCLs);
+  }
 
-  /** 
-   * Get the policy for indexing category <b>ordinals</b>, 
-   * used for deciding how "high" to climb in taxonomy 
-   * from a category when ingesting its ordinals 
+  /**
+   * Returns the delimiter character used internally for concatenating category
+   * path components, e.g. for drill-down terms.
    */
-  public OrdinalPolicy getOrdinalPolicy();
-  
-  /** 
-   * Get the delimiter character used internally for drill-down terms 
-   */ 
-  public char getFacetDelimChar();
+  public char getFacetDelimChar() {
+    return DEFAULT_FACET_DELIM_CHAR;
+  }
+
 }

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/params/PerDimensionIndexingParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/params/PerDimensionIndexingParams.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/params/PerDimensionIndexingParams.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/params/PerDimensionIndexingParams.java Thu Dec 13 12:45:53 2012
@@ -2,7 +2,9 @@ package org.apache.lucene.facet.index.pa
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.lucene.facet.taxonomy.CategoryPath;
 
@@ -24,62 +26,59 @@ import org.apache.lucene.facet.taxonomy.
  */
 
 /**
- * A FacetIndexingParams that utilizes different category lists, defined by the
- * dimension specified CategoryPaths (see
- * {@link PerDimensionIndexingParams#addCategoryListParams(CategoryPath, CategoryListParams)}
+ * A {@link FacetIndexingParams} that utilizes different category lists, defined
+ * by the dimension specified by a {@link CategoryPath category} (see
+ * {@link #PerDimensionIndexingParams(Map, CategoryListParams)}.
  * <p>
  * A 'dimension' is defined as the first or "zero-th" component in a
- * CategoryPath. For example, if a CategoryPath is defined as
- * "/Author/American/Mark Twain", then the dimension is "Author".
- * <p>
- * This class also uses the 'default' CategoryListParams (as specified by
- * {@link CategoryListParams#CategoryListParams()} when
- * {@link #getCategoryListParams(CategoryPath)} is called for a CategoryPath
- * whose dimension component has not been specifically defined.
+ * {@link CategoryPath}. For example, if a category is defined as
+ * "Author/American/Mark Twain", then the dimension would be "Author".
  * 
  * @lucene.experimental
  */
-public class PerDimensionIndexingParams extends DefaultFacetIndexingParams {
+public class PerDimensionIndexingParams extends FacetIndexingParams {
 
-  // "Root" or "first component" of a Category Path maps to a
-  // CategoryListParams
-  private final Map<String, CategoryListParams> clParamsMap = new HashMap<String, CategoryListParams>();
+  private final Map<String, CategoryListParams> clParamsMap;
 
   /**
-   * Construct with the default {@link CategoryListParams} as the default
-   * CategoryListParams for unspecified CategoryPaths.
+   * Initializes a new instance with the given dimension-to-params mapping. The
+   * dimension is considered as what's returned by
+   * {@link CategoryPath#getComponent(int) cp.getComponent(0)}.
+   * 
+   * <p>
+   * <b>NOTE:</b> for any dimension whose {@link CategoryListParams} is not
+   * defined in the mapping, a default {@link CategoryListParams} will be used.
+   * 
+   * @see #PerDimensionIndexingParams(Map, CategoryListParams)
    */
-  public PerDimensionIndexingParams() {
-    this(new CategoryListParams());
+  public PerDimensionIndexingParams(Map<CategoryPath, CategoryListParams> paramsMap) {
+    this(paramsMap, DEFAULT_CATEGORY_LIST_PARAMS);
   }
 
   /**
-   * Construct with the included categoryListParams as the default
-   * CategoryListParams for unspecified CategoryPaths.
-   * 
-   * @param categoryListParams
-   *            the default categoryListParams to use
+   * Same as {@link #PerDimensionIndexingParams(Map)}, only the given
+   * {@link CategoryListParams} will be used for any dimension that is not
+   * specified in the given mapping.
    */
-  public PerDimensionIndexingParams(CategoryListParams categoryListParams) {
+  public PerDimensionIndexingParams(Map<CategoryPath, CategoryListParams> paramsMap, 
+      CategoryListParams categoryListParams) {
     super(categoryListParams);
+    clParamsMap = new HashMap<String,CategoryListParams>();
+    for (Entry<CategoryPath, CategoryListParams> e : paramsMap.entrySet()) {
+      clParamsMap.put(e.getKey().getComponent(0), e.getValue());
+    }
   }
 
-  /**
-   * Get all the categoryListParams, including the default.
-   */
   @Override
-  public Iterable<CategoryListParams> getAllCategoryListParams() {
-    ArrayList<CategoryListParams> vals = 
-      new ArrayList<CategoryListParams>(clParamsMap.values());
-    for (CategoryListParams clp : super.getAllCategoryListParams()) {
-      vals.add(clp);
-    }
+  public List<CategoryListParams> getAllCategoryListParams() {
+    ArrayList<CategoryListParams> vals = new ArrayList<CategoryListParams>(clParamsMap.values());
+    vals.add(clParams); // add the default too
     return vals;
   }
 
   /**
-   * Get the CategoryListParams based on the dimension or "zero-th category"
-   * of the specified CategoryPath.
+   * Returns the {@link CategoryListParams} for the corresponding dimension
+   * which is returned by {@code category.getComponent(0)}.
    */
   @Override
   public CategoryListParams getCategoryListParams(CategoryPath category) {
@@ -89,14 +88,7 @@ public class PerDimensionIndexingParams 
         return clParams;
       }
     }
-    return super.getCategoryListParams(category);
+    return clParams;
   }
 
-  /**
-   * Add a CategoryListParams for a given CategoryPath's dimension or
-   * "zero-th" category.
-   */
-  public void addCategoryListParams(CategoryPath category, CategoryListParams clParams) {
-    clParamsMap.put(category.getComponent(0), clParams);
-  }
 }

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/streaming/CategoryParentsStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/streaming/CategoryParentsStream.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/streaming/CategoryParentsStream.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/index/streaming/CategoryParentsStream.java Thu Dec 13 12:45:53 2012
@@ -154,20 +154,17 @@ public class CategoryParentsStream exten
    * using {@link #addRetainableProperty(Class)}.
    */
   protected void clearCategoryProperties() {
-    if (this.retainableProperties == null
-        || this.retainableProperties.isEmpty()) {
-      this.categoryAttribute.clearProperties();
+    if (retainableProperties == null || retainableProperties.isEmpty()) {
+      categoryAttribute.clearProperties();
     } else {
-      List<Class<? extends CategoryProperty>> propertyClassesToRemove = 
-                            new LinkedList<Class<? extends CategoryProperty>>();
-      for (Class<? extends CategoryProperty> propertyClass : this.categoryAttribute
-          .getPropertyClasses()) {
-        if (!this.retainableProperties.contains(propertyClass)) {
-          propertyClassesToRemove.add(propertyClass);
+      List<Class<? extends CategoryProperty>> propsToRemove = new LinkedList<Class<? extends CategoryProperty>>();
+      for (Class<? extends CategoryProperty> propertyClass : categoryAttribute.getPropertyClasses()) {
+        if (!retainableProperties.contains(propertyClass)) {
+          propsToRemove.add(propertyClass);
         }
       }
-      for (Class<? extends CategoryProperty> propertyClass : propertyClassesToRemove) {
-        this.categoryAttribute.remove(propertyClass);
+      for (Class<? extends CategoryProperty> propertyClass : propsToRemove) {
+        categoryAttribute.remove(propertyClass);
       }
     }
   }

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/StandardFacetsAccumulator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/StandardFacetsAccumulator.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/StandardFacetsAccumulator.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/StandardFacetsAccumulator.java Thu Dec 13 12:45:53 2012
@@ -83,7 +83,7 @@ public class StandardFacetsAccumulator e
     this.facetArrays = facetArrays;
     // can only be computed later when docids size is known
     isUsingComplements = false;
-    partitionSize = PartitionsUtils.partitionSize(searchParams, taxonomyReader);
+    partitionSize = PartitionsUtils.partitionSize(searchParams.getFacetIndexingParams(), taxonomyReader);
     maxPartitions = (int) Math.ceil(this.taxonomyReader.getSize() / (double) partitionSize);
     accumulateGuard = new Object();
   }
@@ -91,7 +91,7 @@ public class StandardFacetsAccumulator e
   public StandardFacetsAccumulator(FacetSearchParams searchParams,
       IndexReader indexReader, TaxonomyReader taxonomyReader) {
     this(searchParams, indexReader, taxonomyReader, new FacetArrays(
-        PartitionsUtils.partitionSize(searchParams, taxonomyReader)));
+        PartitionsUtils.partitionSize(searchParams.getFacetIndexingParams(), taxonomyReader)));
   }
 
   @Override
@@ -109,7 +109,7 @@ public class StandardFacetsAccumulator e
         try {
           totalFacetCounts = TotalFacetCountsCache.getSingleton()
             .getTotalCounts(indexReader, taxonomyReader,
-                searchParams.getFacetIndexingParams(), searchParams.getClCache());
+                searchParams.getFacetIndexingParams(), searchParams.getCategoryListCache());
           if (totalFacetCounts != null) {
             docids = ScoredDocIdsUtils.getComplementSet(docids, indexReader);
           } else {
@@ -135,11 +135,7 @@ public class StandardFacetsAccumulator e
           isUsingComplements = false;
         } catch (Exception e) {
           // give up: this should not happen!
-          IOException ioEx = new IOException(
-              "PANIC: Got unexpected exception while trying to get/calculate total counts: "
-              +e.getMessage());
-          ioEx.initCause(e);
-          throw ioEx;
+          throw new IOException("PANIC: Got unexpected exception while trying to get/calculate total counts", e);
         }
       }
 

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TotalFacetCounts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TotalFacetCounts.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TotalFacetCounts.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TotalFacetCounts.java Thu Dec 13 12:45:53 2012
@@ -8,21 +8,25 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.lucene.index.IndexReader;
-
 import org.apache.lucene.facet.index.params.CategoryListParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.search.aggregator.Aggregator;
 import org.apache.lucene.facet.search.aggregator.CountingAggregator;
 import org.apache.lucene.facet.search.cache.CategoryListCache;
 import org.apache.lucene.facet.search.cache.CategoryListData;
+import org.apache.lucene.facet.search.params.CountFacetRequest;
+import org.apache.lucene.facet.search.params.FacetRequest;
 import org.apache.lucene.facet.search.params.FacetSearchParams;
+import org.apache.lucene.facet.taxonomy.CategoryPath;
 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
 import org.apache.lucene.facet.util.PartitionsUtils;
 import org.apache.lucene.facet.util.ScoredDocIdsUtils;
+import org.apache.lucene.index.IndexReader;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -146,13 +150,17 @@ public class TotalFacetCounts {
       dos.close();
     }
   }
+  
+  // needed because FacetSearchParams do not allow empty FacetRequests
+  private static final List<FacetRequest> DUMMY_REQ = Arrays.asList(
+      new FacetRequest[] { new CountFacetRequest(new CategoryPath(), 1) });
 
   static TotalFacetCounts compute(final IndexReader indexReader,
       final TaxonomyReader taxonomy, final FacetIndexingParams facetIndexingParams,
       final CategoryListCache clCache) throws IOException {
     int partitionSize = PartitionsUtils.partitionSize(facetIndexingParams, taxonomy);
     final int[][] counts = new int[(int) Math.ceil(taxonomy.getSize()  /(float) partitionSize)][partitionSize];
-    FacetSearchParams newSearchParams = new FacetSearchParams(facetIndexingParams); 
+    FacetSearchParams newSearchParams = new FacetSearchParams(DUMMY_REQ, facetIndexingParams); 
       //createAllListsSearchParams(facetIndexingParams,  this.totalCounts);
     FacetsAccumulator fe = new StandardFacetsAccumulator(newSearchParams, indexReader, taxonomy) {
       @Override

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetRequest.java Thu Dec 13 12:45:53 2012
@@ -332,7 +332,7 @@ public abstract class FacetRequest imple
   public CategoryListIterator createCategoryListIterator(IndexReader reader,
       TaxonomyReader taxo, FacetSearchParams sParams, int partition)
       throws IOException {
-    CategoryListCache clCache = sParams.getClCache();
+    CategoryListCache clCache = sParams.getCategoryListCache();
     CategoryListParams clParams = sParams.getFacetIndexingParams().getCategoryListParams(categoryPath);
     if (clCache!=null) {
       CategoryListData clData = clCache.get(clParams);

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetSearchParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetSearchParams.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetSearchParams.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/params/FacetSearchParams.java Thu Dec 13 12:45:53 2012
@@ -1,12 +1,10 @@
 package org.apache.lucene.facet.search.params;
 
-import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.search.cache.CategoryListCache;
-import org.apache.lucene.facet.search.results.FacetResult;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -26,12 +24,13 @@ import org.apache.lucene.facet.search.re
  */
 
 /**
- * Faceted search parameters indicate for which facets should info be gathered.
+ * Defines parameters that are needed for faceted search. The list of
+ * {@link FacetRequest facet requests} denotes the facets for which aggregated
+ * should be done.
  * <p>
- * The contained facet requests define for which facets should info be gathered.
- * <p>
- * Contained faceted indexing parameters provide required info on how
- * to read and interpret the underlying faceted information in the search index.   
+ * One can pass {@link FacetIndexingParams} in order to tell the search code how
+ * to read the facets information. Note that you must use the same
+ * {@link FacetIndexingParams} that were used for indexing.
  * 
  * @lucene.experimental
  */
@@ -39,64 +38,63 @@ public class FacetSearchParams {
 
   protected final FacetIndexingParams indexingParams;
   protected final List<FacetRequest> facetRequests;
-  private CategoryListCache clCache = null;
+  
+  /**
+   * Initializes with the given {@link FacetRequest requests} and default
+   * {@link FacetIndexingParams#ALL_PARENTS}. If you used a different
+   * {@link FacetIndexingParams}, you should use
+   * {@link #FacetSearchParams(List, FacetIndexingParams)}.
+   */
+  public FacetSearchParams(FacetRequest... facetRequests) {
+    this(Arrays.asList(facetRequests), FacetIndexingParams.ALL_PARENTS);
+  }
+  
+  /**
+   * Initializes with the given {@link FacetRequest requests} and default
+   * {@link FacetIndexingParams#ALL_PARENTS}. If you used a different
+   * {@link FacetIndexingParams}, you should use
+   * {@link #FacetSearchParams(List, FacetIndexingParams)}.
+   */
+  public FacetSearchParams(List<FacetRequest> facetRequests) {
+    this(facetRequests, FacetIndexingParams.ALL_PARENTS);
+  }
 
   /**
-   * Construct with specific faceted indexing parameters.
-   * It is important to know the indexing parameters so as to e.g. 
-   * read facets data correctly from the index.
-   * {@link #addFacetRequest(FacetRequest)} must be called at least once 
-   * for this faceted search to find any faceted result.
-   * @param indexingParams Indexing faceted parameters which were used at indexing time.
-   * @see #addFacetRequest(FacetRequest)
+   * Initilizes with the given {@link FacetRequest requests} and
+   * {@link FacetIndexingParams}.
    */
-  public FacetSearchParams(FacetIndexingParams indexingParams) {
+  public FacetSearchParams(List<FacetRequest> facetRequests, FacetIndexingParams indexingParams) {
+    if (facetRequests == null || facetRequests.size() == 0) {
+      throw new IllegalArgumentException("at least one FacetRequest must be defined");
+    }
     this.indexingParams = indexingParams;
-    facetRequests = new ArrayList<FacetRequest>();
+    this.facetRequests = facetRequests;
   }
 
   /**
-   * Construct with default faceted indexing parameters.
-   * Usage of this constructor is valid only if also during indexing the 
-   * default faceted indexing parameters were used.   
-   * {@link #addFacetRequest(FacetRequest)} must be called at least once 
-   * for this faceted search to find any faceted result.
-   * @see #addFacetRequest(FacetRequest)
+   * Returns the {@link CategoryListCache}. By default returns {@code null}, you
+   * should override if you want to use a cache.
    */
-  public FacetSearchParams() {
-    this(new DefaultFacetIndexingParams());
+  public CategoryListCache getCategoryListCache() {
+    return null;
   }
 
   /**
-   * A list of {@link FacetRequest} objects, determining what to count.
-   * If the returned collection is empty, the faceted search will return no facet results!
+   * Returns the {@link FacetIndexingParams} that were passed to the
+   * constructor.
    */
-  public final FacetIndexingParams getFacetIndexingParams() {
+  public FacetIndexingParams getFacetIndexingParams() {
     return indexingParams;
   }
-
+  
   /**
-   * Parameters which controlled the indexing of facets, and which are also
-   * needed during search.
+   * Returns the list of {@link FacetRequest facet requests} that were passed to
+   * the constructor.
    */
-  public final List<FacetRequest> getFacetRequests() {
+  public List<FacetRequest> getFacetRequests() {
     return facetRequests;
   }
 
-  /**
-   * Add a facet request to apply for this faceted search.
-   * This method must be called at least once for faceted search 
-   * to find any faceted result. <br>
-   * NOTE: The order of addition implies the order of the {@link FacetResult}s
-   * @param facetRequest facet request to be added.
-   */
-  public void addFacetRequest(FacetRequest facetRequest) {
-    if (facetRequest == null) {
-      throw new IllegalArgumentException("Provided facetRequest must not be null");
-    }
-    facetRequests.add(facetRequest);
-  }
-  
   @Override
   public String toString() {
     final char TAB = '\t';
@@ -112,19 +110,4 @@ public class FacetSearchParams {
     
     return sb.toString();
   }
-
-  /**
-   * @return the cldCache in effect
-   */
-  public CategoryListCache getClCache() {
-    return clCache;
-  }
-
-  /**
-   * Set Cached Category Lists data to be used in Faceted search.
-   * @param clCache the cldCache to set
-   */
-  public void setClCache(CategoryListCache clCache) {
-    this.clCache = clCache;
-  }
 }

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java Thu Dec 13 12:45:53 2012
@@ -1,6 +1,8 @@
 package org.apache.lucene.facet.search.sampling;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.lucene.index.IndexReader;
 
@@ -183,11 +185,12 @@ public abstract class Sampler {
     // So now we can sample -> altering the searchParams to accommodate for the statistical error for the sampling
     double overSampleFactor = getSamplingParams().getOversampleFactor();
     if (overSampleFactor > 1) { // any factoring to do?
-      res = new FacetSearchParams(original.getFacetIndexingParams());
-      for (FacetRequest frq: original.getFacetRequests()) {
+      List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
+      for (FacetRequest frq : original.getFacetRequests()) {
         int overSampledNumResults = (int) Math.ceil(frq.getNumResults() * overSampleFactor);
-        res.addFacetRequest(new OverSampledFacetRequest(frq, overSampledNumResults));
+        facetRequests.add(new OverSampledFacetRequest(frq, overSampledNumResults));
       }
+      res = new FacetSearchParams(facetRequests, original.getFacetIndexingParams());
     }
     return res;
   }

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/util/PartitionsUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/util/PartitionsUtils.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/util/PartitionsUtils.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/util/PartitionsUtils.java Thu Dec 13 12:45:53 2012
@@ -2,7 +2,6 @@ package org.apache.lucene.facet.util;
 
 import org.apache.lucene.facet.index.params.CategoryListParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
-import org.apache.lucene.facet.search.params.FacetSearchParams;
 import org.apache.lucene.facet.taxonomy.TaxonomyReader;
 
 /*
@@ -33,22 +32,12 @@ public final class PartitionsUtils {
    * Get the offset for a given partition.  That is, what is the minimum number an
    * ordinal could be for a particular partition. 
    */
-  public final static int partitionOffset (  FacetIndexingParams iParams, 
-                        int partitionNumber, 
-                        final TaxonomyReader taxonomyReader) {
+  public final static int partitionOffset(FacetIndexingParams iParams,
+      int partitionNumber, final TaxonomyReader taxonomyReader) {
     return partitionNumber * partitionSize(iParams, taxonomyReader);
   }
 
   /**
-   * @see #partitionOffset(FacetIndexingParams, int, TaxonomyReader)
-   */
-  public final static int partitionOffset (  FacetSearchParams sParams, 
-                        int partitionNumber, 
-                        final TaxonomyReader taxonomyReader) {
-    return partitionOffset(sParams.getFacetIndexingParams(), partitionNumber, taxonomyReader);
-  }
-
-  /**
    * Get the partition size in this parameter, or return the size of the taxonomy, which
    * is smaller.  (Guarantees usage of as little memory as possible at search time).
    */
@@ -57,13 +46,6 @@ public final class PartitionsUtils {
   }
 
   /**
-   * @see #partitionSize(FacetIndexingParams, TaxonomyReader)
-   */
-  public final static int partitionSize(FacetSearchParams sParams, final TaxonomyReader taxonomyReader) {
-    return partitionSize(sParams.getFacetIndexingParams(), taxonomyReader);
-  }
-
-  /**
    * Partition number of an ordinal.
    * <p>
    * This allows to locate the partition containing a certain (facet) ordinal.
@@ -74,19 +56,11 @@ public final class PartitionsUtils {
   }
 
   /**
-   * @see #partitionNumber(FacetIndexingParams, int)
-   */
-  public final static int partitionNumber(FacetSearchParams sParams, int ordinal) {
-    return partitionNumber(sParams.getFacetIndexingParams(), ordinal);
-  }
-
-  /**
    * Partition name by category ordinal
    */
-  public final static String partitionNameByOrdinal(  FacetIndexingParams iParams, 
-                            CategoryListParams clParams, 
-                            int ordinal) {
-    int partition = partitionNumber(iParams, ordinal); 
+  public final static String partitionNameByOrdinal(
+      FacetIndexingParams iParams, CategoryListParams clParams, int ordinal) {
+    int partition = partitionNumber(iParams, ordinal);
     return partitionName(clParams, partition);
   }
 

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java Thu Dec 13 12:45:53 2012
@@ -15,6 +15,18 @@ import org.apache.lucene.analysis.MockTo
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.TextField;
+import org.apache.lucene.facet.index.CategoryDocumentBuilder;
+import org.apache.lucene.facet.index.params.CategoryListParams;
+import org.apache.lucene.facet.index.params.FacetIndexingParams;
+import org.apache.lucene.facet.search.params.FacetRequest;
+import org.apache.lucene.facet.search.params.FacetSearchParams;
+import org.apache.lucene.facet.search.results.FacetResult;
+import org.apache.lucene.facet.search.results.FacetResultNode;
+import org.apache.lucene.facet.taxonomy.CategoryPath;
+import org.apache.lucene.facet.taxonomy.TaxonomyReader;
+import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
+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.DocsEnum;
 import org.apache.lucene.index.IndexReader;
@@ -28,24 +40,10 @@ import org.apache.lucene.index.TermsEnum
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.store.Directory;
-
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util._TestUtil;
-import org.apache.lucene.facet.index.CategoryDocumentBuilder;
-import org.apache.lucene.facet.index.params.CategoryListParams;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
-import org.apache.lucene.facet.index.params.FacetIndexingParams;
-import org.apache.lucene.facet.search.params.FacetRequest;
-import org.apache.lucene.facet.search.params.FacetSearchParams;
-import org.apache.lucene.facet.search.results.FacetResult;
-import org.apache.lucene.facet.search.results.FacetResultNode;
-import org.apache.lucene.facet.taxonomy.CategoryPath;
-import org.apache.lucene.facet.taxonomy.TaxonomyReader;
-import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
-import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
-import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
@@ -184,29 +182,28 @@ public abstract class FacetTestBase exte
 
   /** Returns a default facet indexing params */
   protected FacetIndexingParams getFacetIndexingParams(final int partSize) {
-    return new DefaultFacetIndexingParams() {
+    return new FacetIndexingParams() {
       @Override
-      protected int fixedPartitionSize() {
+      public int getPartitionSize() {
         return partSize;
       }
     };
   }
   
   /**
-   * Faceted Search Params for the test.
-   * Sub classes should override in order to test with different faceted search params.
+   * Faceted Search Params for the test. Sub classes should override in order to
+   * test with different faceted search params.
    */
-  protected FacetSearchParams getFacetedSearchParams() {
-    return getFacetedSearchParams(Integer.MAX_VALUE);
+  protected FacetSearchParams getFacetSearchParams(FacetIndexingParams iParams, FacetRequest... facetRequests) {
+    return new FacetSearchParams(Arrays.asList(facetRequests), iParams);
   }
 
   /**
-   * Faceted Search Params with specified partition size.
-   * @see #getFacetedSearchParams()
+   * Faceted Search Params for the test. Sub classes should override in order to
+   * test with different faceted search params.
    */
-  protected FacetSearchParams getFacetedSearchParams(int partitionSize) {
-    FacetSearchParams res = new FacetSearchParams(getFacetIndexingParams(partitionSize));
-    return res; 
+  protected FacetSearchParams getFacetSearchParams(List<FacetRequest> facetRequests, FacetIndexingParams iParams) {
+    return new FacetSearchParams(facetRequests, iParams);
   }
 
   /**

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java Thu Dec 13 12:45:53 2012
@@ -2,26 +2,13 @@ package org.apache.lucene.facet;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collection;
+import java.util.List;
 
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.DirectoryReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexWriterConfig;
-import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.search.Collector;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.search.TopScoreDocCollector;
-import org.apache.lucene.store.Directory;
-
-import org.apache.lucene.search.MultiCollector;
-import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.facet.index.CategoryDocumentBuilder;
-import org.apache.lucene.facet.index.params.DefaultFacetIndexingParams;
 import org.apache.lucene.facet.index.params.FacetIndexingParams;
 import org.apache.lucene.facet.search.FacetsCollector;
 import org.apache.lucene.facet.search.params.CountFacetRequest;
@@ -32,6 +19,17 @@ import org.apache.lucene.facet.taxonomy.
 import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
 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.index.RandomIndexWriter;
+import org.apache.lucene.search.Collector;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.MultiCollector;
+import org.apache.lucene.search.TopScoreDocCollector;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.LuceneTestCase;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -91,19 +89,18 @@ public class FacetTestUtils {
   }
 
   public static Collector[] search(IndexSearcher searcher,
-      TaxonomyReader taxonomyReader, DefaultFacetIndexingParams iParams,
-      int k, String... facetNames) throws IOException {
+      TaxonomyReader taxonomyReader, FacetIndexingParams iParams, int k,
+      String... facetNames) throws IOException {
     
     Collector[] collectors = new Collector[2];
     
-    FacetSearchParams facetSearchParams = new FacetSearchParams(iParams);
-    Collection<FacetRequest> fRequests = new ArrayList<FacetRequest>();
+    List<FacetRequest> fRequests = new ArrayList<FacetRequest>();
     for (String facetName : facetNames) {
       CategoryPath cp = new CategoryPath(facetName);
       FacetRequest fq = new CountFacetRequest(cp, k);
-      facetSearchParams.addFacetRequest(fq);
       fRequests.add(fq);
     }
+    FacetSearchParams facetSearchParams = new FacetSearchParams(fRequests, iParams);
 
     TopScoreDocCollector topDocsCollector = TopScoreDocCollector.create(
         searcher.getIndexReader().maxDoc(), true);

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy1.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy1.java?rev=1421262&r1=1421261&r2=1421262&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy1.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/enhancements/CategoryEnhancementDummy1.java Thu Dec 13 12:45:53 2012
@@ -56,7 +56,7 @@ public class CategoryEnhancementDummy1 i
   }
 
   @Override
-  public Class<? extends CategoryProperty> getRetainableProperty() {
+  public CategoryProperty getRetainableProperty() {
     return null;
   }
 



Mime
View raw message