Class FacetsConfig

java.lang.Object
org.apache.lucene.facet.FacetsConfig
Direct Known Subclasses:
OrdinalMappingLeafReader.InnerFacetsConfig

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.

  • Field Details

  • Constructor Details

    • FacetsConfig

      public FacetsConfig()
      Default constructor.
  • Method Details

    • 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.
    • isDimConfigured

      public boolean isDimConfigured(String dimName)
      Returns true if the dimension for provided name has ever been manually configured. The opposite means that dimension is still valid and DEFAULT_DIM_CONFIG is being used for it.
    • 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 value)
      Pass true if this dimension may have more than one value per document.
    • setRequireDimCount

      public void setRequireDimCount(String dimName, boolean value)
      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.
    • setDrillDownTermsIndexing

      public void setDrillDownTermsIndexing(String dimName, FacetsConfig.DrillDownTermsIndexing drillDownTermsIndexing)
      Specify drill down terms option on the field / dimension.
    • getDimConfigs

      public Map<String,FacetsConfig.DimConfig> getDimConfigs()
      Returns map of field name to FacetsConfig.DimConfig.
    • checkSeen

      private static void checkSeen(Set<String> seenDims, String dim)
    • build

      public Document build(Document doc) throws IOException
      Translates any added FacetFields 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 FacetFields into normal fields for indexing.

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

      Throws:
      IOException
    • processFacetFields

      private void processFacetFields(TaxonomyWriter taxoWriter, Map<String,List<FacetField>> byField, Document doc) throws IOException
      Throws:
      IOException
    • indexDrillDownTerms

      private void indexDrillDownTerms(Document doc, String indexFieldName, FacetsConfig.DimConfig dimConfig, FacetLabel facetLabel)
    • processSSDVFacetFields

      private void processSSDVFacetFields(Map<String,List<SortedSetDocValuesFacetField>> byField, Document doc)
    • processAssocFacetFields

      private void processAssocFacetFields(TaxonomyWriter taxoWriter, Map<String,List<AssociationFacetField>> byField, Document doc) throws IOException
      Throws:
      IOException
    • dedupAndEncode

      @Deprecated protected BytesRef dedupAndEncode(IntsRef ordinals)
      Deprecated.
      Starting in Lucene 9, we moved to a more straight-forward numeric doc values encoding and no longer support custom binary encodings.
      Encodes ordinals into a BytesRef; expert: subclass can override this to change encoding.
    • checkTaxoWriter

      private void checkTaxoWriter(TaxonomyWriter taxoWriter)
    • 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[].