mirror of https://github.com/apache/lucene.git
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:
parent
4193bce372
commit
074923dda7
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue