Package org.apache.lucene.facet
Class FacetsConfig
- java.lang.Object
-
- org.apache.lucene.facet.FacetsConfig
-
public class FacetsConfig extends java.lang.Object
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FacetsConfig.DimConfig
Holds the configuration for one dimension
-
Field Summary
Fields Modifier and Type Field Description static FacetsConfig.DimConfig
DEFAULT_DIM_CONFIG
Default per-dimension configuration.static java.lang.String
DEFAULT_INDEX_FIELD_NAME
Which Lucene field holds the drill-downs and ords (as doc values).
-
Constructor Summary
Constructors Constructor Description FacetsConfig()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Document
build(Document doc)
Translates any addedFacetField
s into normal fields for indexing; only use this version if you did not add any taxonomy-based fields (FacetField
orAssociationFacetField
).Document
build(TaxonomyWriter taxoWriter, Document doc)
Translates any addedFacetField
s into normal fields for indexing.FacetsConfig.DimConfig
getDimConfig(java.lang.String dimName)
Get the current configuration for a dimension.java.util.Map<java.lang.String,FacetsConfig.DimConfig>
getDimConfigs()
Returns map of field name toFacetsConfig.DimConfig
.static java.lang.String
pathToString(java.lang.String[] path)
Turns a dim + path into an encoded string.static java.lang.String
pathToString(java.lang.String[] path, int length)
Turns the firstlength
elements ofpath
into an encoded string.static java.lang.String
pathToString(java.lang.String dim, java.lang.String[] path)
Turns a dim + path into an encoded string.void
setHierarchical(java.lang.String dimName, boolean v)
Passtrue
if this dimension is hierarchical (has depth > 1 paths).void
setIndexFieldName(java.lang.String dimName, java.lang.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(java.lang.String dimName, boolean v)
Passtrue
if this dimension may have more than one value per document.void
setRequireDimCount(java.lang.String dimName, boolean v)
Passtrue
if at search time you require accurate counts of the dimension, i.e.static java.lang.String[]
stringToPath(java.lang.String s)
Turns an encoded string (from a previous call topathToString(java.lang.String, java.lang.String[])
) back into the originalString[]
.
-
-
-
Field Detail
-
DEFAULT_INDEX_FIELD_NAME
public static final java.lang.String DEFAULT_INDEX_FIELD_NAME
Which Lucene field holds the drill-downs and ords (as doc values).- See Also:
- Constant Field Values
-
DEFAULT_DIM_CONFIG
public static final FacetsConfig.DimConfig DEFAULT_DIM_CONFIG
Default per-dimension configuration.
-
-
Method Detail
-
getDimConfig
public FacetsConfig.DimConfig getDimConfig(java.lang.String dimName)
Get the current configuration for a dimension.
-
setHierarchical
public void setHierarchical(java.lang.String dimName, boolean v)
Passtrue
if this dimension is hierarchical (has depth > 1 paths).
-
setMultiValued
public void setMultiValued(java.lang.String dimName, boolean v)
Passtrue
if this dimension may have more than one value per document.
-
setRequireDimCount
public void setRequireDimCount(java.lang.String dimName, boolean v)
Passtrue
if at search time you require accurate counts of the dimension, i.e. how many hits have this dimension.
-
setIndexFieldName
public void setIndexFieldName(java.lang.String dimName, java.lang.String indexFieldName)
Specify which index field name should hold the ordinals for this dimension; this is only used by the taxonomy based facet methods.
-
getDimConfigs
public java.util.Map<java.lang.String,FacetsConfig.DimConfig> getDimConfigs()
Returns map of field name toFacetsConfig.DimConfig
.
-
build
public Document build(Document doc) throws java.io.IOException
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:
java.io.IOException
-
build
public Document build(TaxonomyWriter taxoWriter, Document doc) throws java.io.IOException
Translates any addedFacetField
s into normal fields for indexing.NOTE: you should add the returned document to IndexWriter, not the input one!
- Throws:
java.io.IOException
-
pathToString
public static java.lang.String pathToString(java.lang.String dim, java.lang.String[] path)
Turns a dim + path into an encoded string.
-
pathToString
public static java.lang.String pathToString(java.lang.String[] path)
Turns a dim + path into an encoded string.
-
pathToString
public static java.lang.String pathToString(java.lang.String[] path, int length)
Turns the firstlength
elements ofpath
into an encoded string.
-
stringToPath
public static java.lang.String[] stringToPath(java.lang.String s)
Turns an encoded string (from a previous call topathToString(java.lang.String, java.lang.String[])
) back into the originalString[]
.
-
-