org.apache.lucene.facet

## Class FacetsConfig

- java.lang.Object
- - org.apache.lucene.facet.FacetsConfig

-     public class FacetsConfig
      extends 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.

  WARNING: This API is experimental and might change in incompatible ways in the next release.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `FacetsConfig.DimConfig` Holds the configuration for one dimension

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static FacetsConfig.DimConfig` | `DEFAULT_DIM_CONFIG` Default per-dimension configuration.
    `static String` | `DEFAULT_INDEX_FIELD_NAME` Which Lucene field holds the drill-downs and ords (as doc values).

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FacetsConfig()` Default constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Document` | `build(Document doc)` Translates any added `FacetField`s into normal fields for indexing; only use this version if you did not add any taxonomy-based fields ( `FacetField` or `AssociationFacetField`).
    `Document` | `build(TaxonomyWriter taxoWriter, Document doc)` Translates any added `FacetField`s into normal fields for indexing.
    `protected BytesRef` | `dedupAndEncode(IntsRef ordinals)` Encodes ordinals into a BytesRef; expert: subclass can override this to change encoding.
    `protected FacetsConfig.DimConfig` | `getDefaultDimConfig()` Get the default configuration for new dimensions.
    `FacetsConfig.DimConfig` | `getDimConfig(String dimName)` Get the current configuration for a dimension.
    `Map<String,FacetsConfig.DimConfig>` | `getDimConfigs()` Returns map of field name to `FacetsConfig.DimConfig`.
    `static String` | `pathToString(String[] path)` Turns a dim + path into an encoded string.
    `static String` | `pathToString(String[] path, int length)` Turns the first `length` elements of `path` into an encoded string.
    `static String` | `pathToString(String dim, String[] path)` Turns a dim + path into an encoded string.
    `void` | `setHierarchical(String dimName, boolean v)` Pass `true` 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 v)` Pass `true` if this dimension may have more than one value per document.
    `void` | `setRequireDimCount(String dimName, boolean v)` Pass `true` if at search time you require accurate counts of the dimension, i.e.
    `void` | `setRequireDimensionDrillDown(String dimName, boolean v)` Specify whether drill down on just the dimension is necessary.
    `static String[]` | `stringToPath(String s)` Turns an encoded string (from a previous call to `pathToString(java.lang.String, java.lang.String[])`) back into the original `String[]`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_INDEX_FIELD_NAME

          public static final 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.

  - ### Constructor Detail

    - #### FacetsConfig

          public FacetsConfig()

      Default constructor.

  - ### Method Detail

    - #### getDefaultDimConfig

          protected FacetsConfig.DimConfig getDefaultDimConfig()

      Get the default configuration for new dimensions. Useful when the dimension is not known beforehand and may need different global default settings, like `multivalue = true`.
      Returns:
        The default configuration to be used for dimensions that are not yet set in the `FacetsConfig`

    - #### getDimConfig

          public FacetsConfig.DimConfig getDimConfig(String dimName)

      Get the current configuration for a dimension.

    - #### setHierarchical

          public void setHierarchical(String dimName,
                                      boolean v)

      Pass `true` if this dimension is hierarchical (has depth > 1 paths).

    - #### setMultiValued

          public void setMultiValued(String dimName,
                                     boolean v)

      Pass `true` if this dimension may have more than one value per document.

    - #### setRequireDimCount

          public void setRequireDimCount(String dimName,
                                         boolean v)

      Pass `true` if at search time you require accurate counts of the dimension, i.e. how many hits have this dimension.

    - #### setIndexFieldName

          public 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.

    - #### setRequireDimensionDrillDown

          public void setRequireDimensionDrillDown(String dimName,
                                                   boolean v)

      Specify whether drill down on just the dimension is necessary.

    - #### getDimConfigs

          public Map<String,FacetsConfig.DimConfig> getDimConfigs()

      Returns map of field name to `FacetsConfig.DimConfig`.

    - #### build

          public Document build(Document doc)
                         throws IOException

      Translates any added `FacetField`s into normal fields for indexing; only use this version if you did not add any taxonomy-based fields ( `FacetField` or `AssociationFacetField`).

      NOTE: you should add the returned document to IndexWriter, not the input one!

      Throws:
        `IOException`

    - #### build

          public Document build(TaxonomyWriter taxoWriter,
                                Document doc)
                         throws IOException

      Translates any added `FacetField`s into normal fields for indexing.

      NOTE: you should add the returned document to IndexWriter, not the input one!

      Throws:
        `IOException`

    - #### dedupAndEncode

          protected BytesRef dedupAndEncode(IntsRef ordinals)

      Encodes ordinals into a BytesRef; expert: subclass can override this to change encoding.

    - #### pathToString

          public static String pathToString(String dim,
                                            String[] path)

      Turns a dim + path into an encoded string.

    - #### pathToString

          public static String pathToString(String[] path)

      Turns a dim + path into an encoded string.

    - #### pathToString

          public static String pathToString(String[] path,
                                            int length)

      Turns the first `length` elements of `path` into an encoded string.

    - #### stringToPath

          public static String[] stringToPath(String s)

      Turns an encoded string (from a previous call to `pathToString(java.lang.String, java.lang.String[])`) back into the original `String[]`.

Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.