org.compass.core.mapping.osem.builder
Class SearchableMappingBuilder

java.lang.Object
  extended by org.compass.core.mapping.osem.builder.SearchableMappingBuilder
All Implemented Interfaces:
ResourceMappingProvider

public class SearchableMappingBuilder
extends Object
implements ResourceMappingProvider

Marks a class as searchable. A searchable class is assoiated with an alias, and allows to perform full text search on it's mapped properties/fields.

The searchable class is associated with an alias, which can be used to reference the class when performing search operations, or for other mappings to extend it. By default, teh alias name will be the class short name.

Note, a root searchable must be associated with at least one SearchableIdMappingBuilder.

By default, the searchable class is defined as a root class. A root class is a top level searchable class. A non root class can be used to define mappings definitions for SearchableComponentMappingBuilder, and it is preferable that classes that are only used as component mapping definitions, will be defined with root(boolean) set to false.

A class mapping has it's own fully functional index, unless using the subIndex(String) to join several searchable classes into the same index (when joining several searchalbe classes into the same index, the search will be much faster, but updates perform locks on the sub index level, so it might slow it down). More fine grained control can be acheived using subIndex(org.compass.core.engine.subindex.SubIndexHash) allowing to parition the same class into several sub indexes using ModuloSubIndexHash definition.

A searchable class creates an internal "all" meta-data, which holds searchable information of all the class searchable content. Controlling the "all" property using the SearchableAllMappingBuilder and setting it using all(SearchableAllMappingBuilder).

The seachable class can have a specialized analyzer (different from the default one) associated with it using analyzer(String). Note, that this will associate the class statically with an analyzer. Dynamically associating the class with an analyzer, the SearchableAnalyzerMappingBuilder can be used to annotated the dynamic value for the analyzer to use.

The poly(boolean) can be used to mapped polymprphic inheritance tree. This is the less prefable way to map an inhertiance tree, since the fact that a searchable class extend other searchable classes using the extendsAliases(String[]) mapping.

Author:
kimchy
See Also:
OSEM.searchable(Class)

Constructor Summary
SearchableMappingBuilder(Class clazz)
          Constructs a new class mapping builder for the specified class.
 
Method Summary
 SearchableMappingBuilder add(SearchableAnalyzerMappingBuilder builder)
          Adds an analyzer proeprty mapping to the searchable class.
 SearchableMappingBuilder add(SearchableBoostMappingBuilder builder)
          Adds a boost property mapping to the searchable class.
 SearchableMappingBuilder add(SearchableCascadeMappingBuilder builder)
          Addsa cascade mapping to the searchable class.
 SearchableMappingBuilder add(SearchableComponentMappingBuilder builder)
          Adds a component mapping to the searchable class.
 SearchableMappingBuilder add(SearchableConstantMappingBuilder builder)
          Adds a constant mapping to the searchable class.
 SearchableMappingBuilder add(SearchableDynamicMetaDataMappingBuilder builder)
          Adds a dynamic meta data mapping to the searchable class.
 SearchableMappingBuilder add(SearchableDynamicPropertyMappingBuilder builder)
          Adds a dynamic property mapping to searchable class.
 SearchableMappingBuilder add(SearchableIdComponentMappingBuilder builder)
          Adds an id component mapping to the searchable class.
 SearchableMappingBuilder add(SearchableIdMappingBuilder builder)
          Adds an id property mapping to the searchable class.
 SearchableMappingBuilder add(SearchableParentMappingBuilder builder)
          Adds parent mapping to the searchable class.
 SearchableMappingBuilder add(SearchablePropertyMappingBuilder builder)
          Adds a proeprty mapping to the searchable class.
 SearchableMappingBuilder add(SearchableReferenceMappingBuilder builder)
          Adds a reference mapping to the searchable class.
 SearchableMappingBuilder alias(String alias)
          Sets the alias of the searchable class.
 SearchableMappingBuilder all(SearchableAllMappingBuilder builder)
          Allows to set the "all" mapping definition.
 SearchableMappingBuilder analyzer(String analyzer)
          The name of the analyzer that will be used to analyze ANALYZED properties.
 SearchableMappingBuilder boost(float boost)
          Sets the boost value for the class.
 SearchableMappingBuilder extendsAliases(String... extendedAliases)
          Sets the list of other clas mappings that this mapping will extend and inherit internal mappings from.
 SearchableMappingBuilder filterDuplicatesDuringUnmarshalling(boolean filterDuplicatesDuringUnamrshalling)
          Should the searchable class filter out duplicates during unmarshalling.
 ResourceMapping getMapping()
          Returns the mapping.
 SearchableMappingBuilder managedId(ManagedId managedId)
          Controls the managed id value for all the mapped properties that have no explicit setting of the managed id (also default to NA).
 SearchableMappingBuilder mappingConverter(Converter converter)
          Sets the mapping converter that will be used to convert the class.
 SearchableMappingBuilder mappingConverter(String converter)
          Sets the mapping converter lookup name that will be used to convert the class.
 SearchableMappingBuilder poly(boolean poly)
          Used to mapped polymprphic inheritance tree.
 SearchableMappingBuilder polyClass(Class polyClass)
          In cases where poly is set to true, allows to set the class that will be used to instantiate in all inheritance tree cases.
 SearchableMappingBuilder root(boolean root)
          Sets if the class is a root mapping or not.
 SearchableMappingBuilder spellCheck(SpellCheck spellCheck)
          Sets the spell check mode that will be used for this class mapping (and for all the internal mappings that do not explicitly set their own spell check mode).
 SearchableMappingBuilder subIndex(String subIndex)
          Sets a sub index that will be used for this resource.
 SearchableMappingBuilder subIndex(SubIndexHash subIndexHash)
          Sets a custom sub index hashing strategy for the resource mapping.
 SearchableMappingBuilder supportUnmarshall(boolean supportUnmarshall)
          Controls if the searchable class will support unamrsahlling or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchableMappingBuilder

public SearchableMappingBuilder(Class clazz)
Constructs a new class mapping builder for the specified class.

Method Detail

getMapping

public ResourceMapping getMapping()
Returns the mapping.

Specified by:
getMapping in interface ResourceMappingProvider

alias

public SearchableMappingBuilder alias(String alias)
Sets the alias of the searchable class. By default, will be set to the class short name. Note, the alias must be set before any addition of child mappings using add.


root

public SearchableMappingBuilder root(boolean root)
Sets if the class is a root mapping or not. Root searchable classes are classes that will have be mapped to a sub index, and will return as actual hits from search results. Mostly. non root searchable classes are classes that are only used as component mappings. Defaults to true.


supportUnmarshall

public SearchableMappingBuilder supportUnmarshall(boolean supportUnmarshall)
Controls if the searchable class will support unamrsahlling or not. When the searchable class supprots unmarshalling, then when loading to from the index, it will be constructed fully from the index. When it does not support unamrshalling, then only the ids of the searchable class will be filled.

When supporting unmarshalling, Compass might store additional properties in the resource that represents this searchable class (for example, to store the size of a collection). Note, when support unamrshalling is set to false, then one can still use the Resource loaded from the index.

Defaults to the a globabl setting CompassEnvironment.Osem.SUPPORT_UNMARSHALL which in turn defaults to true.


filterDuplicatesDuringUnmarshalling

public SearchableMappingBuilder filterDuplicatesDuringUnmarshalling(boolean filterDuplicatesDuringUnamrshalling)
Should the searchable class filter out duplicates during unmarshalling. Defaults to CompassEnvironment.Osem.FILTER_DUPLICATES.


poly

public SearchableMappingBuilder poly(boolean poly)
Used to mapped polymprphic inheritance tree. This is the less prefable way to map an inheritance tree, since the searchable class can extend other searchable classes using extendsAliases(String[]).

If poly is set to true, the actual class implementation will be persisted to the index, later be used to instantiate it when un-marhsalling. If a specific class need to be used to instantiate all classes, use the {polyClass(Class) to set it.


polyClass

public SearchableMappingBuilder polyClass(Class polyClass)
In cases where poly is set to true, allows to set the class that will be used to instantiate in all inheritance tree cases.

If not set, the actual class will be saved to the index, later be used to instantiate it when un-marhsalling


managedId

public SearchableMappingBuilder managedId(ManagedId managedId)
Controls the managed id value for all the mapped properties that have no explicit setting of the managed id (also default to NA). The default value for the managed id is derived from globabl Compass settings and defaults to ManagedId.NO_STORE.


subIndex

public SearchableMappingBuilder subIndex(String subIndex)
Sets a sub index that will be used for this resource. Basically uses ConstantSubIndexHash.


subIndex

public SearchableMappingBuilder subIndex(SubIndexHash subIndexHash)
Sets a custom sub index hashing strategy for the resource mapping.


extendsAliases

public SearchableMappingBuilder extendsAliases(String... extendedAliases)
Sets the list of other clas mappings that this mapping will extend and inherit internal mappings from.


spellCheck

public SearchableMappingBuilder spellCheck(SpellCheck spellCheck)
Sets the spell check mode that will be used for this class mapping (and for all the internal mappings that do not explicitly set their own spell check mode). If not set will use the global spell check setting.


analyzer

public SearchableMappingBuilder analyzer(String analyzer)
The name of the analyzer that will be used to analyze ANALYZED properties. Defaults to the default analyzer which is one of the internal analyzers that comes with Compass. If not set, will use the default analyzer.

Note, that when using the class-analyzer mapping (a child mapping of class mapping) (for a class property value that controls the analyzer), the analyzer attribute will have no effects.


boost

public SearchableMappingBuilder boost(float boost)
Sets the boost value for the class.


all

public SearchableMappingBuilder all(SearchableAllMappingBuilder builder)
Allows to set the "all" mapping definition.


mappingConverter

public SearchableMappingBuilder mappingConverter(String converter)
Sets the mapping converter lookup name that will be used to convert the class. Defaults to ClassMappingConverter.


mappingConverter

public SearchableMappingBuilder mappingConverter(Converter converter)
Sets the mapping converter that will be used to convert the class. Defaults to ClassMappingConverter.


add

public SearchableMappingBuilder add(SearchableIdMappingBuilder builder)
Adds an id property mapping to the searchable class.


add

public SearchableMappingBuilder add(SearchablePropertyMappingBuilder builder)
Adds a proeprty mapping to the searchable class.


add

public SearchableMappingBuilder add(SearchableDynamicPropertyMappingBuilder builder)
Adds a dynamic property mapping to searchable class.


add

public SearchableMappingBuilder add(SearchableAnalyzerMappingBuilder builder)
Adds an analyzer proeprty mapping to the searchable class.


add

public SearchableMappingBuilder add(SearchableBoostMappingBuilder builder)
Adds a boost property mapping to the searchable class.


add

public SearchableMappingBuilder add(SearchableComponentMappingBuilder builder)
Adds a component mapping to the searchable class.


add

public SearchableMappingBuilder add(SearchableIdComponentMappingBuilder builder)
Adds an id component mapping to the searchable class.


add

public SearchableMappingBuilder add(SearchableReferenceMappingBuilder builder)
Adds a reference mapping to the searchable class.


add

public SearchableMappingBuilder add(SearchableConstantMappingBuilder builder)
Adds a constant mapping to the searchable class.


add

public SearchableMappingBuilder add(SearchableDynamicMetaDataMappingBuilder builder)
Adds a dynamic meta data mapping to the searchable class.


add

public SearchableMappingBuilder add(SearchableCascadeMappingBuilder builder)
Addsa cascade mapping to the searchable class.


add

public SearchableMappingBuilder add(SearchableParentMappingBuilder builder)
Adds parent mapping to the searchable class.



Copyright (c) 2004-2009 The Compass Project.