|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.facet.index.CategoryDocumentBuilder
public class CategoryDocumentBuilder
A utility class which allows attachment of CategoryPath
s or
CategoryAttribute
s to a given document using a taxonomy.
Construction could be done with either a given FacetIndexingParams
or
the default implementation DefaultFacetIndexingParams
.
A CategoryDocumentBuilder can be reused by repeatedly setting the categories
and building the document. Categories are provided either as
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)
.
Field Summary | |
---|---|
protected Map<String,List<CategoryAttribute>> |
categoriesMap
|
protected ArrayList<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 Summary | |
---|---|
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. |
Method Summary | |
---|---|
Document |
build(Document doc)
Adds the fields created in one of the "set" methods to the document |
protected void |
fillCategoriesMap(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(TokenStream categoryStream)
Get a category list tokenizer (or a series of such tokenizers) to create the category list tokens. |
protected CategoryTokenizer |
getCategoryTokenizer(TokenStream categoryStream)
Get a CategoryTokenizer to create the category tokens. |
protected CountingListTokenizer |
getCountingListTokenizer(TokenStream categoryStream)
Get a CountingListTokenizer for creating counting list token. |
protected TokenStream |
getParentsStream(CategoryAttributesStream categoryAttributesStream)
Get a stream of categories which includes the parents, according to policies defined in indexing parameters. |
CategoryDocumentBuilder |
setCategories(Iterable<CategoryAttribute> categories)
Set the categories of the document builder from an Iterable of
CategoryAttribute objects. |
CategoryDocumentBuilder |
setCategoryPaths(Iterable<CategoryPath> categoryPaths)
Set the categories of the document builder from an Iterable of
CategoryPath objects. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final TaxonomyWriter taxonomyWriter
TaxonomyWriter
for adding categories and retrieving their
ordinals.
protected final FacetIndexingParams indexingParams
protected final ArrayList<Field> fieldList
build(Document)
.
protected Map<String,List<CategoryAttribute>> categoriesMap
Constructor Detail |
---|
public CategoryDocumentBuilder(TaxonomyWriter taxonomyWriter) throws IOException
CategoryDocumentBuilder(TaxonomyWriter, FacetIndexingParams)
taxonomyWriter
- to which new categories will be added, as well as translating
known categories to ordinals
IOException
public CategoryDocumentBuilder(TaxonomyWriter taxonomyWriter, FacetIndexingParams params) throws 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 parameters
IOException
Method Detail |
---|
public CategoryDocumentBuilder setCategoryPaths(Iterable<CategoryPath> categoryPaths) throws 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)
.
IOException
public CategoryDocumentBuilder setCategories(Iterable<CategoryAttribute> categories) throws 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)
.
IOException
protected TokenStream getParentsStream(CategoryAttributesStream categoryAttributesStream)
categoryAttributesStream
- The input stream
OrdinalPolicy (for policy of adding category tokens for parents)
,
PathPolicy (for policy of adding category list tokens for parents)
protected void fillCategoriesMap(Iterable<CategoryAttribute> categories) throws IOException
FacetIndexingParams
object
categories
- Iterable over the category attributes
IOException
protected CategoryListTokenizer getCategoryListTokenizer(TokenStream categoryStream)
categoryStream
- A stream containing CategoryAttribute
with the
relevant data.
protected CountingListTokenizer getCountingListTokenizer(TokenStream categoryStream)
CountingListTokenizer
for creating counting list token.
categoryStream
- A stream containing CategoryAttribute
s with the
relevant data.
protected CategoryTokenizer getCategoryTokenizer(TokenStream categoryStream) throws 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.
IOException
public Document build(Document doc)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |