Interface CategoryEnhancement
-
- All Known Implementing Classes:
AssociationEnhancement
public interface CategoryEnhancementThis interface allows easy addition of enhanced category features. Usually, aCategoryEnhancementwill correspond to aCategoryProperty.A category enhancement can contribute to the index in two possible ways:
- To each category with data relevant to the enhancement, add this data to
the category's token payload, through
getCategoryTokenBytes(CategoryAttribute). This data will be read during search usingextractCategoryTokenData(byte[], int, int). - To each document which contains categories with data relevant to the
enhancement, add a
CategoryListTokenizerthroughgetCategoryListTokenizer(TokenStream, EnhancementsIndexingParams, TaxonomyWriter). TheCategoryListTokenizershould add a single token which includes all the enhancement relevant data from the categories. The category list token's text is defined bygetCategoryListTermText().
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanequals(Object o)Category enhancements must overrideObject.equals(Object), as it is used inEnhancementsPayloadIterator.getCategoryData(CategoryEnhancement).ObjectextractCategoryTokenData(byte[] buffer, int offset, int length)Get the data of this enhancement from a category token payload.booleangeneratesCategoryList()Declarative method to indicate whether this enhancement generates separate category list.StringgetCategoryListTermText()Returns the text of this enhancement's category list term.CategoryListTokenizergetCategoryListTokenizer(org.apache.lucene.analysis.TokenStream tokenizer, EnhancementsIndexingParams indexingParams, TaxonomyWriter taxonomyWriter)Get theCategoryListTokenizerwhich generates the category list for this enhancement.byte[]getCategoryTokenBytes(CategoryAttribute categoryAttribute)Get the bytes to be added to the category token payload for this enhancement.Class<? extends CategoryProperty>getRetainableProperty()Get aCategoryPropertyclass to be retained when creatingCategoryParentsStream.
-
-
-
Method Detail
-
getCategoryTokenBytes
byte[] getCategoryTokenBytes(CategoryAttribute categoryAttribute)
Get the bytes to be added to the category token payload for this enhancement.NOTE: The returned array is copied, it is recommended to allocate a new one each time.
The bytes generated by this method are the input of
extractCategoryTokenData(byte[], int, int).- Parameters:
categoryAttribute- The attribute of the category.- Returns:
- The bytes to be added to the category token payload for this enhancement.
-
extractCategoryTokenData
Object extractCategoryTokenData(byte[] buffer, int offset, int length)
Get the data of this enhancement from a category token payload.The input bytes for this method are generated in
getCategoryTokenBytes(CategoryAttribute).- Parameters:
buffer- The payload buffer.offset- The offset of this enhancement's data in the buffer.length- The length of this enhancement's data (bytes).- Returns:
- An Object containing the data.
-
generatesCategoryList
boolean generatesCategoryList()
Declarative method to indicate whether this enhancement generates separate category list.- Returns:
trueif generates category list, elsefalse.
-
getCategoryListTermText
String getCategoryListTermText()
Returns the text of this enhancement's category list term.- Returns:
- The text of this enhancement's category list term.
-
getCategoryListTokenizer
CategoryListTokenizer getCategoryListTokenizer(org.apache.lucene.analysis.TokenStream tokenizer, EnhancementsIndexingParams indexingParams, TaxonomyWriter taxonomyWriter)
Get theCategoryListTokenizerwhich generates the category list for this enhancement. IfgeneratesCategoryList()returnsfalsethis method will not be called.- Parameters:
tokenizer- The input stream containing categories.indexingParams- The indexing params to use.taxonomyWriter- The taxonomy to add categories and get their ordinals.- Returns:
- A
CategoryListTokenizergenerating the category list for this enhancement, withtokenizeras it's input.
-
getRetainableProperty
Class<? extends CategoryProperty> getRetainableProperty()
Get aCategoryPropertyclass to be retained when creatingCategoryParentsStream.- Returns:
- the
CategoryPropertyclass to be retained when creatingCategoryParentsStream, ornullif there is no such property.
-
equals
boolean equals(Object o)
Category enhancements must overrideObject.equals(Object), as it is used inEnhancementsPayloadIterator.getCategoryData(CategoryEnhancement).
-
-