Interface ITaxonomyWriter
ITaxonomyWriter is the interface which the faceted-search library uses to dynamically build the taxonomy at indexing time.
Notes about concurrent access to the taxonomy:
An implementation must allow multiple readers and a single writer to be active concurrently. Readers follow so-called "point in time" semantics, i.e., a reader object will only see taxonomy entries which were available at the time it was created. What the writer writes is only available to (new) readers after the writer's Commit() is called.
Faceted search keeps two indices - namely Lucene's main index, and this taxonomy index. When one or more readers are active concurrently with the writer, care must be taken to avoid an inconsistency between the state of these two indices: When writing to the indices, the taxonomy must always be committed to disk before the main index, because the main index refers to categories listed in the taxonomy. Such control can best be achieved by turning off the main index's "autocommit" feature, and explicitly calling Commit() for both indices (first for the taxonomy, then for the main index). In old versions of Lucene (2.2 or earlier), when autocommit could not be turned off, a more complicated solution needs to be used. E.g., use some sort of (possibly inter-process) locking to ensure that a reader is being opened only right after both indices have been flushed (and before anything else is written to them).
@lucene.experimental
Inherited Members
Assembly: DistributedLucene.Net.Facet.dll
Syntax
public interface ITaxonomyWriter : IDisposable, ITwoPhaseCommit, IIdentifiableSurrogate
Properties
Name | Description |
---|---|
CommitData | Returns the commit user data map that was set on SetCommitData(IDictionary<String, String>). |
Count | Count returns the number of categories in the taxonomy. Because categories are numbered consecutively starting with 0, it means the taxonomy contains ordinals 0 through Count-1. Note that the number returned by Count is often slightly higher than the number of categories inserted into the taxonomy; This is because when a category is added to the taxonomy, its ancestors are also added automatically (including the root, which always get ordinal 0). |
Methods
Name | Description |
---|---|
AddCategory(FacetLabel) | AddCategory(FacetLabel) adds a category with a given path name to the taxonomy, and returns its ordinal. If the category was already present in the taxonomy, its existing ordinal is returned. Before adding a category, AddCategory(FacetLabel) makes sure that all its ancestor categories exist in the taxonomy as well. As result, the ordinal of a category is guaranteed to be smaller then the ordinal of any of its descendants. |
SetCommitData(IDictionary<String, String>) | Sets the commit user data map. That method is considered a transaction and will be committed (Commit()) even if no other changes were made to the writer instance. NOTE: the map is cloned internally, therefore altering the map's contents after calling this method has no effect. |