Interface CategoryEnhancement
-
- All Known Implementing Classes:
AssociationEnhancement
public interface CategoryEnhancement
This interface allows easy addition of enhanced category features. Usually, aCategoryEnhancement
will 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
CategoryListTokenizer
throughgetCategoryListTokenizer(TokenStream, EnhancementsIndexingParams, TaxonomyWriter)
. TheCategoryListTokenizer
should 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 boolean
equals(Object o)
Category enhancements must overrideObject.equals(Object)
, as it is used inEnhancementsPayloadIterator.getCategoryData(CategoryEnhancement)
.Object
extractCategoryTokenData(byte[] buffer, int offset, int length)
Get the data of this enhancement from a category token payload.boolean
generatesCategoryList()
Declarative method to indicate whether this enhancement generates separate category list.String
getCategoryListTermText()
Returns the text of this enhancement's category list term.CategoryListTokenizer
getCategoryListTokenizer(org.apache.lucene.analysis.TokenStream tokenizer, EnhancementsIndexingParams indexingParams, TaxonomyWriter taxonomyWriter)
Get theCategoryListTokenizer
which 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 aCategoryProperty
class 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:
true
if 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 theCategoryListTokenizer
which generates the category list for this enhancement. IfgeneratesCategoryList()
returnsfalse
this 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
CategoryListTokenizer
generating the category list for this enhancement, withtokenizer
as it's input.
-
getRetainableProperty
Class<? extends CategoryProperty> getRetainableProperty()
Get aCategoryProperty
class to be retained when creatingCategoryParentsStream
.- Returns:
- the
CategoryProperty
class to be retained when creatingCategoryParentsStream
, ornull
if there is no such property.
-
equals
boolean equals(Object o)
Category enhancements must overrideObject.equals(Object)
, as it is used inEnhancementsPayloadIterator.getCategoryData(CategoryEnhancement)
.
-
-