LUCENE-5479: make the default dimension config controllable via subclass of FacetsConfig

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1573156 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2014-03-01 11:44:49 +00:00
parent 4193bce372
commit 074923dda7
3 changed files with 29 additions and 2 deletions

View File

@ -84,6 +84,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

View File

@ -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;
}

View File

@ -84,5 +84,18 @@ public class TestFacetsConfig extends FacetTestCase {
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);
}
}