lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1573157 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/CHANGES.txt lucene/facet/ lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java lucene/facet/src/test/org/apache/lucene/facet/TestFacetsConfig.java
Date Sat, 01 Mar 2014 11:45:53 GMT
Author: mikemccand
Date: Sat Mar  1 11:45:53 2014
New Revision: 1573157

URL: http://svn.apache.org/r1573157
Log:
LUCENE-5479: make the default dimension config controllable via subclass of FacetsConfig

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/java/org/apache/lucene/facet/FacetsConfig.java
    lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/TestFacetsConfig.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=1573157&r1=1573156&r2=1573157&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Sat Mar  1 11:45:53 2014
@@ -21,6 +21,9 @@ New Features
 * LUCENE-5482: Improve default TurkishAnalyzer by adding apostrophe
   handling suitable for Turkish.  (Ahmet Arslan via Robert Muir)
 
+* LUCENE-5479: FacetsConfig subclass can now customize the default
+  per-dim facets configuration.  (Rob Audenaerde via Mike McCandless)
+
 API Changes
 
 * LUCENE-5454: Add RandomAccessOrds, an optional extension of SortedSetDocValues

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java?rev=1573157&r1=1573156&r2=1573157&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/FacetsConfig.java
Sat Mar  1 11:45:53 2014
@@ -98,11 +98,22 @@ public class FacetsConfig {
   public FacetsConfig() {
   }
 
+  /** Get the default configuration for new dimensions.  Useful when
+   *  the dimension is not known beforehand and may need different 
+   *  global default settings, like {@code multivalue =
+   *  true}.
+   *
+   *  @return The default configuration to be used for dimensions that 
+   *  are not yet set in the {@link FacetsConfig} */
+  protected DimConfig getDefaultDimConfig(){
+    return DEFAULT_DIM_CONFIG;
+  }
+  
   /** Get the current configuration for a dimension. */
   public synchronized DimConfig getDimConfig(String dimName) {
     DimConfig ft = fieldTypes.get(dimName);
     if (ft == null) {
-      ft = DEFAULT_DIM_CONFIG;
+      ft = getDefaultDimConfig();
     }
     return ft;
   }

Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/TestFacetsConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/TestFacetsConfig.java?rev=1573157&r1=1573156&r2=1573157&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/TestFacetsConfig.java
(original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/TestFacetsConfig.java
Sat Mar  1 11:45:53 2014
@@ -84,5 +84,18 @@ public class TestFacetsConfig extends Fa
     
     IOUtils.close(indexDir, taxoDir);
   }
-  
+
+  /** LUCENE-5479 */
+  public void testCustomDefault() {
+    FacetsConfig config = new FacetsConfig() {
+        @Override
+        protected DimConfig getDefaultDimConfig() {
+          DimConfig config = new DimConfig();
+          config.hierarchical = true;
+          return config;
+        }
+      };
+
+    assertTrue(config.getDimConfig("foobar").hierarchical);
+  }
 }



Mime
View raw message