[hibernate-commits] Hibernate SVN: r15613 - search/trunk/src/java/org/hibernate/search/engine.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Nov 25 10:05:59 EST 2008


Author: hardy.ferentschik
Date: 2008-11-25 10:05:58 -0500 (Tue, 25 Nov 2008)
New Revision: 15613

Modified:
   search/trunk/src/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java
Log:
added some documentation

Modified: search/trunk/src/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java	2008-11-25 13:29:35 UTC (rev 15612)
+++ search/trunk/src/java/org/hibernate/search/engine/DocumentBuilderIndexedEntity.java	2008-11-25 15:05:58 UTC (rev 15613)
@@ -328,29 +328,39 @@
 		super.addWorkToQueue( entityClass, entity, id, workType, queue, searchFactoryImplementor );
 	}
 
+	/**
+	 * Builds the Lucene <code>Document</code> for a given entity <code>instance</code> and its <code>id</code>.
+	 *
+	 * @param instance The entity for which to build the matching Lucene <code>Document</code>
+	 * @param id the entity id.
+	 * @return The Lucene <code>Document</code> for the specified entity.
+	 */
 	public Document getDocument(T instance, Serializable id) {
 		Document doc = new Document();
 		final Class<?> entityType = Hibernate.getClass( instance );
-		//XClass instanceClass = reflectionManager.toXClass( entityType );
 		if ( metadata.boost != null ) {
 			doc.setBoost( metadata.boost );
 		}
-		{
-			Field classField =
-					new Field(
-							CLASS_FIELDNAME,
-							entityType.getName(),
-							Field.Store.YES,
-							Field.Index.NOT_ANALYZED,
-							Field.TermVector.NO
-					);
-			doc.add( classField );
-			LuceneOptions luceneOptions = new LuceneOptionsImpl(
-					Field.Store.YES,
-					Field.Index.NOT_ANALYZED, Field.TermVector.NO, idBoost
-			);
-			idBridge.set( idKeywordName, id, doc, luceneOptions );
-		}
+
+		// add the class name of the entity to the document
+		Field classField =
+				new Field(
+						CLASS_FIELDNAME,
+						entityType.getName(),
+						Field.Store.YES,
+						Field.Index.NOT_ANALYZED,
+						Field.TermVector.NO
+				);
+		doc.add( classField );
+
+		// now add the entity id to the document
+		LuceneOptions luceneOptions = new LuceneOptionsImpl(
+				Field.Store.YES,
+				Field.Index.NOT_ANALYZED, Field.TermVector.NO, idBoost
+		);
+		idBridge.set( idKeywordName, id, doc, luceneOptions );
+
+		// finally add all other document fields
 		buildDocumentFields( instance, doc, metadata );
 		return doc;
 	}




More information about the hibernate-commits mailing list