Annotation idAnnotation = getIdAnnotation( member, context );
if ( idAnnotation != null ) {
String attributeName = getIdAttributeName( member, idAnnotation );
if ( isRoot ) {
if ( idKeywordName != null && explicitDocumentId ) {
throw new AssertionFailure( "Two document id assigned: "
+ idKeywordName + " and " + attributeName );
}
idKeywordName = prefix + attributeName;
FieldBridge fieldBridge = BridgeFactory.guessType( null, member, reflectionManager );
if ( fieldBridge instanceof TwoWayFieldBridge ) {
idBridge = (TwoWayFieldBridge) fieldBridge;
}
else {
throw new SearchException(
"Bridge for document id does not implement TwoWayFieldBridge: " + member.getName() );
}
idBoost = getBoost( member, null );
setAccessible( member );
idGetter = member;
}
else {
//component should index their document id
setAccessible( member );
propertiesMetadata.fieldGetters.add( member );
String fieldName = prefix + attributeName;
propertiesMetadata.fieldNames.add( fieldName );
propertiesMetadata.fieldStore.add( getStore( Store.YES ) );
propertiesMetadata.fieldIndex.add( getIndex( Index.UN_TOKENIZED ) );
propertiesMetadata.fieldTermVectors.add( getTermVector( TermVector.NO ) );
propertiesMetadata.fieldBridges.add( BridgeFactory.guessType( null, member, reflectionManager ) );
propertiesMetadata.fieldBoosts.add( getBoost( member, null ) );
// property > entity analyzer (no field analyzer)
Analyzer analyzer = getAnalyzer( member, context );
if ( analyzer == null ) analyzer = propertiesMetadata.analyzer;
if ( analyzer == null ) throw new AssertionFailure( "Analizer should not be undefined" );
this.analyzer.addScopedAnalyzer( fieldName, analyzer );
}
}
}