org.hibernate.search.engine
Class DocumentBuilderIndexedEntity<T>

java.lang.Object
  extended by org.hibernate.search.engine.DocumentBuilderContainedEntity<T>
      extended by org.hibernate.search.engine.DocumentBuilderIndexedEntity<T>
All Implemented Interfaces:
DocumentBuilder

public class DocumentBuilderIndexedEntity<T>
extends DocumentBuilderContainedEntity<T>

Set up and provide a manager for classes which are directly annotated with @Indexed.

Author:
Gavin King, Emmanuel Bernard, Sylvain Vieujot, Richard Hallier, Hardy Ferentschik

Nested Class Summary
 
Nested classes/interfaces inherited from class org.hibernate.search.engine.DocumentBuilderContainedEntity
DocumentBuilderContainedEntity.PropertiesMetadata
 
Field Summary
protected  org.hibernate.annotations.common.reflection.XMember idGetter
          The class member used as document id.
protected  String idKeywordName
          Name of the document id field.
 
Fields inherited from class org.hibernate.search.engine.DocumentBuilderContainedEntity
analyzer, beanClass, entityState, isRoot, level, mappedSubclasses, maxLevel, metadata, reflectionManager, similarity
 
Fields inherited from interface org.hibernate.search.engine.DocumentBuilder
CLASS_FIELDNAME
 
Constructor Summary
DocumentBuilderIndexedEntity(org.hibernate.annotations.common.reflection.XClass clazz, InitContext context, DirectoryProvider[] directoryProviders, IndexShardingStrategy shardingStrategy, org.hibernate.annotations.common.reflection.ReflectionManager reflectionManager)
          Creates a document builder for entities annotated with @Indexed.
 
Method Summary
 void addWorkToQueue(Class<T> entityClass, T entity, Serializable id, WorkType workType, List<LuceneWork> queue, SearchFactoryImplementor searchFactoryImplementor)
           
 boolean allowFieldSelectionInProjection()
           
protected  void checkDocumentId(org.hibernate.annotations.common.reflection.XProperty member, DocumentBuilderContainedEntity.PropertiesMetadata propertiesMetadata, boolean isRoot, String prefix, InitContext context)
           
 DirectoryProvider[] getDirectoryProviders()
           
 IndexShardingStrategy getDirectoryProviderSelectionStrategy()
           
 org.apache.lucene.document.Document getDocument(T instance, Serializable id, Map<String,String> fieldToAnalyzerMap)
          Builds the Lucene Document for a given entity instance and its id.
static Class getDocumentClass(org.apache.lucene.document.Document document)
           
static Object[] getDocumentFields(SearchFactoryImplementor searchFactoryImplementor, Class<?> clazz, org.apache.lucene.document.Document document, String[] fields)
           
static Serializable getDocumentId(SearchFactoryImplementor searchFactoryImplementor, Class<?> clazz, org.apache.lucene.document.Document document)
           
 TwoWayFieldBridge getIdBridge()
           
 String getIdentifierName()
           
 String getIdKeywordName()
           
 org.apache.lucene.index.Term getTerm(Serializable id)
           
protected  void init(org.hibernate.annotations.common.reflection.XClass clazz, InitContext context)
           
 boolean isSafeFromTupleId()
           
 
Methods inherited from class org.hibernate.search.engine.DocumentBuilderContainedEntity
getAnalyzer, getAnalyzer, getAnalyzer, getBoost, getBoost, getEntityState, getIdAttributeName, getIndex, getMappedSubclasses, getSimilarity, getStore, getTermVector, initializeMemberLevelAnnotations, isRoot, postInitialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

idGetter

protected org.hibernate.annotations.common.reflection.XMember idGetter
The class member used as document id.


idKeywordName

protected String idKeywordName
Name of the document id field.

Constructor Detail

DocumentBuilderIndexedEntity

public DocumentBuilderIndexedEntity(org.hibernate.annotations.common.reflection.XClass clazz,
                                    InitContext context,
                                    DirectoryProvider[] directoryProviders,
                                    IndexShardingStrategy shardingStrategy,
                                    org.hibernate.annotations.common.reflection.ReflectionManager reflectionManager)
Creates a document builder for entities annotated with @Indexed.

Parameters:
clazz - The class for which to build a DocumentBuilderContainedEntity.
context - Handle to default configuration settings.
directoryProviders - Arrays of directory providers for the underlying Lucene indexes of the indexed entity.
shardingStrategy - The sharding strategy used for the indexed entity.
reflectionManager - Reflection manager to use for processing the annotations.
Method Detail

init

protected void init(org.hibernate.annotations.common.reflection.XClass clazz,
                    InitContext context)
Overrides:
init in class DocumentBuilderContainedEntity<T>

checkDocumentId

protected void checkDocumentId(org.hibernate.annotations.common.reflection.XProperty member,
                               DocumentBuilderContainedEntity.PropertiesMetadata propertiesMetadata,
                               boolean isRoot,
                               String prefix,
                               InitContext context)
Overrides:
checkDocumentId in class DocumentBuilderContainedEntity<T>

addWorkToQueue

public void addWorkToQueue(Class<T> entityClass,
                           T entity,
                           Serializable id,
                           WorkType workType,
                           List<LuceneWork> queue,
                           SearchFactoryImplementor searchFactoryImplementor)
Overrides:
addWorkToQueue in class DocumentBuilderContainedEntity<T>

getDocument

public org.apache.lucene.document.Document getDocument(T instance,
                                                       Serializable id,
                                                       Map<String,String> fieldToAnalyzerMap)
Builds the Lucene Document for a given entity instance and its id.

Parameters:
instance - The entity for which to build the matching Lucene Document
id - the entity id.
fieldToAnalyzerMap - this maps gets populated while generateing the Document. It allows to specify for any document field a named analyzer to use. This parameter cannot be null.
Returns:
The Lucene Document for the specified entity.

getIdentifierName

public String getIdentifierName()

getDirectoryProviders

public DirectoryProvider[] getDirectoryProviders()

getDirectoryProviderSelectionStrategy

public IndexShardingStrategy getDirectoryProviderSelectionStrategy()

allowFieldSelectionInProjection

public boolean allowFieldSelectionInProjection()

isSafeFromTupleId

public boolean isSafeFromTupleId()
Returns:
false if there is a risk of composite id. If composite id, use of (a, b) in ((1,2), (3,4)) fails on most database

getTerm

public org.apache.lucene.index.Term getTerm(Serializable id)

getIdBridge

public TwoWayFieldBridge getIdBridge()

getDocumentClass

public static Class getDocumentClass(org.apache.lucene.document.Document document)

getIdKeywordName

public String getIdKeywordName()

getDocumentId

public static Serializable getDocumentId(SearchFactoryImplementor searchFactoryImplementor,
                                         Class<?> clazz,
                                         org.apache.lucene.document.Document document)

getDocumentFields

public static Object[] getDocumentFields(SearchFactoryImplementor searchFactoryImplementor,
                                         Class<?> clazz,
                                         org.apache.lucene.document.Document document,
                                         String[] fields)