public class CategoryDocumentBuilder
extends java.lang.Object
CategoryPaths or
CategoryAttributes to a given document using a taxonomy.FacetIndexingParams or
the default implementation DefaultFacetIndexingParams.CategoryAttribute elements through setCategories(Iterable),
or as CategoryPath elements through
setCategoryPaths(Iterable).
Note that both setCategories(Iterable) and
setCategoryPaths(Iterable) return this
CategoryDocumentBuilder, allowing the following pattern: new
CategoryDocumentBuilder(taxonomy,
params).setCategories(categories).build(doc).
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,java.util.List<CategoryAttribute>> |
categoriesMap |
protected java.util.ArrayList<org.apache.lucene.document.Field> |
fieldList
A list of fields which is filled at ancestors' construction and used
during
build(Document). |
protected FacetIndexingParams |
indexingParams
Parameters to be used when indexing categories.
|
protected TaxonomyWriter |
taxonomyWriter
A
TaxonomyWriter for adding categories and retrieving their
ordinals. |
| Constructor and Description |
|---|
CategoryDocumentBuilder(TaxonomyWriter taxonomyWriter)
Creating a facets document builder with default facet indexing
parameters.
See: CategoryDocumentBuilder(TaxonomyWriter, FacetIndexingParams) |
CategoryDocumentBuilder(TaxonomyWriter taxonomyWriter,
FacetIndexingParams params)
Creating a facets document builder with a given facet indexing parameters
object.
|
| Modifier and Type | Method and Description |
|---|---|
org.apache.lucene.document.Document |
build(org.apache.lucene.document.Document doc)
Adds the fields created in one of the "set" methods to the document
|
protected void |
fillCategoriesMap(java.lang.Iterable<CategoryAttribute> categories)
Fills the categories mapping between a field name and a list of
categories that belongs to it according to this builder's
FacetIndexingParams object |
protected CategoryListTokenizer |
getCategoryListTokenizer(org.apache.lucene.analysis.TokenStream categoryStream)
Get a category list tokenizer (or a series of such tokenizers) to create
the category list tokens.
|
protected CategoryTokenizer |
getCategoryTokenizer(org.apache.lucene.analysis.TokenStream categoryStream)
Get a
CategoryTokenizer to create the category tokens. |
protected CountingListTokenizer |
getCountingListTokenizer(org.apache.lucene.analysis.TokenStream categoryStream)
Get a
CountingListTokenizer for creating counting list token. |
protected org.apache.lucene.analysis.TokenStream |
getParentsStream(CategoryAttributesStream categoryAttributesStream)
Get a stream of categories which includes the parents, according to
policies defined in indexing parameters.
|
CategoryDocumentBuilder |
setCategories(java.lang.Iterable<CategoryAttribute> categories)
Set the categories of the document builder from an
Iterable of
CategoryAttribute objects. |
CategoryDocumentBuilder |
setCategoryPaths(java.lang.Iterable<CategoryPath> categoryPaths)
Set the categories of the document builder from an
Iterable of
CategoryPath objects. |
protected final TaxonomyWriter taxonomyWriter
TaxonomyWriter for adding categories and retrieving their
ordinals.protected final FacetIndexingParams indexingParams
protected final java.util.ArrayList<org.apache.lucene.document.Field> fieldList
build(Document).protected java.util.Map<java.lang.String,java.util.List<CategoryAttribute>> categoriesMap
public CategoryDocumentBuilder(TaxonomyWriter taxonomyWriter) throws java.io.IOException
CategoryDocumentBuilder(TaxonomyWriter, FacetIndexingParams)taxonomyWriter - to which new categories will be added, as well as translating
known categories to ordinalsjava.io.IOExceptionpublic CategoryDocumentBuilder(TaxonomyWriter taxonomyWriter, FacetIndexingParams params) throws java.io.IOException
taxonomyWriter - to which new categories will be added, as well as translating
known categories to ordinalsparams - holds all parameters the indexing process should use such as
category-list parametersjava.io.IOExceptionpublic CategoryDocumentBuilder setCategoryPaths(java.lang.Iterable<CategoryPath> categoryPaths) throws java.io.IOException
Iterable of
CategoryPath objects.categoryPaths - An iterable of CategoryPath objects which holds the categories
(facets) which will be added to the document at
build(Document)new CategoryDocumentBuilder(TaxonomyWriter).
setCategoryPaths(Iterable).build(Document).java.io.IOExceptionpublic CategoryDocumentBuilder setCategories(java.lang.Iterable<CategoryAttribute> categories) throws java.io.IOException
Iterable of
CategoryAttribute objects.categories - An iterable of CategoryAttribute objects which holds
the categories (facets) which will be added to the document at
build(Document)new CategoryDocumentBuilder(TaxonomyWriter).
setCategories(Iterable).build(Document).java.io.IOExceptionprotected org.apache.lucene.analysis.TokenStream getParentsStream(CategoryAttributesStream categoryAttributesStream)
categoryAttributesStream - The input streamOrdinalPolicy (for policy of adding category tokens for parents),
PathPolicy (for policy of adding category list tokens for parents)protected void fillCategoriesMap(java.lang.Iterable<CategoryAttribute> categories) throws java.io.IOException
FacetIndexingParams objectcategories - Iterable over the category attributesjava.io.IOExceptionprotected CategoryListTokenizer getCategoryListTokenizer(org.apache.lucene.analysis.TokenStream categoryStream)
categoryStream - A stream containing CategoryAttribute with the
relevant data.protected CountingListTokenizer getCountingListTokenizer(org.apache.lucene.analysis.TokenStream categoryStream)
CountingListTokenizer for creating counting list token.categoryStream - A stream containing CategoryAttributes with the
relevant data.protected CategoryTokenizer getCategoryTokenizer(org.apache.lucene.analysis.TokenStream categoryStream) throws java.io.IOException
CategoryTokenizer to create the category tokens.
This method can be overridden for adding more attributes to the category
tokens.categoryStream - A stream containing CategoryAttribute with the
relevant data.CategoryTokenizer to be used in creating category
tokens.java.io.IOExceptionpublic org.apache.lucene.document.Document build(org.apache.lucene.document.Document doc)
Copyright © 2000-2022 Apache Software Foundation. All Rights Reserved.