org.apache.lucene.facet.associations

## Class AssociationsFacetFields

- java.lang.Object
- - org.apache.lucene.facet.index.FacetFields
  - - org.apache.lucene.facet.associations.AssociationsFacetFields

    public class AssociationsFacetFields
    extends FacetFields

A utility class for adding facet fields to a document. Usually one field will be added for all facets, however per the `FacetIndexingParams.getCategoryListParams(CategoryPath)`, one field may be added for every group of facets.

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

### Field Summary

### Fields inherited from class org.apache.lucene.facet.index.FacetFields

`indexingParams, taxonomyWriter`

### Constructor Summary

Constructors
Constructor and Description
`AssociationsFacetFields(TaxonomyWriter taxonomyWriter)` Constructs a new instance with the `default` facet indexing params.
`AssociationsFacetFields(TaxonomyWriter taxonomyWriter, FacetIndexingParams params)` Constructs a new instance with the given facet indexing params.

### Method Summary

Methods
`void` `addFields(Document doc, Iterable<CategoryPath> categories)` Adds the needed facet fields to the document.
`protected Map<CategoryListParams,Iterable<CategoryPath>>` `createCategoryListMapping(Iterable<CategoryPath> categories)` Creates a mapping between a `CategoryListParams` and all `categories` that are associated with it.
`protected FieldType` `drillDownFieldType()` Returns the `FieldType` with which the drill-down terms should be indexed.
`protected Map<String,BytesRef>` `getCategoryListData(CategoryListParams categoryListParams, IntsRef ordinals, Iterable<CategoryPath> categories)` Returns the category list data, as a mapping from key to `BytesRef` which includes the encoded data.
`protected DrillDownStream` `getDrillDownStream(Iterable<CategoryPath> categories)` Returns a `DrillDownStream` for writing the categories drill-down terms.

### Methods inherited from class org.apache.lucene.facet.index.FacetFields

`addCountingListData`

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

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

### Constructor Detail

#### AssociationsFacetFields

    public AssociationsFacetFields(TaxonomyWriter taxonomyWriter)

Constructs a new instance with the `default` facet indexing params.

Parameters:
  `taxonomyWriter` - used to resolve given categories to ordinals

#### AssociationsFacetFields

    public AssociationsFacetFields(TaxonomyWriter taxonomyWriter,
                           FacetIndexingParams params)

Constructs a new instance with the given facet indexing params.

Parameters:
  `taxonomyWriter` - used to resolve given categories to ordinals
  `params` - determines under which fields the categories should be indexed

### Method Detail

#### createCategoryListMapping

    protected Map<CategoryListParams,Iterable<CategoryPath>> createCategoryListMapping(Iterable<CategoryPath> categories)

Description copied from class: `FacetFields`
Creates a mapping between a `CategoryListParams` and all `categories` that are associated with it.

Overrides:
  `createCategoryListMapping` in class `FacetFields`

#### getCategoryListData

    protected Map<String,BytesRef> getCategoryListData(CategoryListParams categoryListParams,
                                           IntsRef ordinals,
                                           Iterable<CategoryPath> categories)
                                                throws IOException

Description copied from class: `FacetFields`
Returns the category list data, as a mapping from key to `BytesRef` which includes the encoded data. Every ordinal in `ordinals` corrspond to a `CategoryPath` returned from `categories`.

Overrides:
  `getCategoryListData` in class `FacetFields`
Throws:
  `IOException`

#### getDrillDownStream

    protected DrillDownStream getDrillDownStream(Iterable<CategoryPath> categories)

Description copied from class: `FacetFields`
Returns a `DrillDownStream` for writing the categories drill-down terms.

Overrides:
  `getDrillDownStream` in class `FacetFields`

#### drillDownFieldType

    protected FieldType drillDownFieldType()

Description copied from class: `FacetFields`
Returns the `FieldType` with which the drill-down terms should be indexed. The default is `FieldInfo.IndexOptions.DOCS_ONLY`.

Overrides:
  `drillDownFieldType` in class `FacetFields`

#### addFields

    public void addFields(Document doc,
                 Iterable<CategoryPath> categories)
                   throws IOException

Description copied from class: `FacetFields`
Adds the needed facet fields to the document.

Overrides:
  `addFields` in class `FacetFields`
Throws:
  `IOException`