Package org.apache.lucene.facet
Class FacetsConfig
java.lang.Object
org.apache.lucene.facet.FacetsConfig
Records per-dimension configuration. By default a dimension is flat, single valued and does not
require count for the dimension; use the setters in this class to change these settings for each
dim.
NOTE: this configuration is not saved into the index, but it's vital, and up to the
application to ensure, that at search time the provided FacetsConfig
matches what was
used during indexing.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Holds the configuration for one dimensionstatic enum
Drill down terms indexing option to control whether dimension and sub-path terms should be indexed. -
Field Summary
Modifier and TypeFieldDescriptionstatic final FacetsConfig.DimConfig
Default per-dimension configuration.static final String
Which Lucene field holds the drill-downs and ords (as doc values).static final char
Character used to join the category path components together into a single drill down term for indexing. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionTranslates any addedFacetField
s into normal fields for indexing; only use this version if you did not add any taxonomy-based fields (FacetField
orAssociationFacetField
).build
(TaxonomyWriter taxoWriter, Document doc) Translates any addedFacetField
s into normal fields for indexing.protected FacetsConfig.DimConfig
Get the default configuration for new dimensions.getDimConfig
(String dimName) Get the current configuration for a dimension.Returns map of field name toFacetsConfig.DimConfig
.boolean
isDimConfigured
(String dimName) Returns true if the dimension for provided name has ever been manually configured.static String
pathToString
(String[] path) Turns a dim + path into an encoded string.static String
pathToString
(String[] path, int length) Turns the firstlength
elements ofpath
into an encoded string.static String
pathToString
(String dim, String... path) Turns a dim + path into an encoded string.void
setDrillDownTermsIndexing
(String dimName, FacetsConfig.DrillDownTermsIndexing drillDownTermsIndexing) Specify drill down terms option on the field / dimension.void
setHierarchical
(String dimName, boolean v) Passtrue
if this dimension is hierarchical (has depth > 1 paths).void
setIndexFieldName
(String dimName, String indexFieldName) Specify which index field name should hold the ordinals for this dimension; this is only used by the taxonomy based facet methods.void
setMultiValued
(String dimName, boolean value) Passtrue
if this dimension may have more than one value per document.void
setRequireDimCount
(String dimName, boolean value) Passtrue
if at search time you require accurate counts of the dimension, i.e.static String[]
Turns an encoded string (from a previous call topathToString(java.lang.String, java.lang.String...)
) back into the originalString[]
.
-
Field Details
-
DEFAULT_INDEX_FIELD_NAME
Which Lucene field holds the drill-downs and ords (as doc values).- See Also:
-
DEFAULT_DIM_CONFIG
Default per-dimension configuration. -
DELIM_CHAR
public static final char DELIM_CHARCharacter used to join the category path components together into a single drill down term for indexing. Applications and unit-tests can reference this for creating their own drill-down terms, or use existing APIs (for example,pathToString(java.lang.String, java.lang.String...)
).- See Also:
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Constructor Details
-
FacetsConfig
public FacetsConfig()Default constructor.
-
-
Method Details
-
getDefaultDimConfig
Get the default configuration for new dimensions. Useful when the dimension is not known beforehand and may need different global default settings, likemultivalue = true
.- Returns:
- The default configuration to be used for dimensions that are not yet set in the
FacetsConfig
-
getDimConfig
Get the current configuration for a dimension. -
isDimConfigured
Returns true if the dimension for provided name has ever been manually configured. The opposite means that dimension is still valid andDEFAULT_DIM_CONFIG
is being used for it. -
setHierarchical
Passtrue
if this dimension is hierarchical (has depth > 1 paths). -
setMultiValued
Passtrue
if this dimension may have more than one value per document. -
setRequireDimCount
Passtrue
if at search time you require accurate counts of the dimension, i.e. how many hits have this dimension. -
setIndexFieldName
Specify which index field name should hold the ordinals for this dimension; this is only used by the taxonomy based facet methods. -
setDrillDownTermsIndexing
public void setDrillDownTermsIndexing(String dimName, FacetsConfig.DrillDownTermsIndexing drillDownTermsIndexing) Specify drill down terms option on the field / dimension. -
getDimConfigs
Returns map of field name toFacetsConfig.DimConfig
. -
build
Translates any addedFacetField
s into normal fields for indexing; only use this version if you did not add any taxonomy-based fields (FacetField
orAssociationFacetField
).NOTE: you should add the returned document to IndexWriter, not the input one!
- Throws:
IOException
-
build
Translates any addedFacetField
s into normal fields for indexing.NOTE: you should add the returned document to IndexWriter, not the input one!
- Throws:
IOException
-
pathToString
Turns a dim + path into an encoded string. -
pathToString
Turns a dim + path into an encoded string. -
pathToString
Turns the firstlength
elements ofpath
into an encoded string. -
stringToPath
Turns an encoded string (from a previous call topathToString(java.lang.String, java.lang.String...)
) back into the originalString[]
.
-