[hibernate-commits] Hibernate SVN: r12895 - trunk/HibernateExt/search/doc/reference/en/modules.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Aug 3 10:31:01 EDT 2007


Author: hardy.ferentschik
Date: 2007-08-03 10:31:01 -0400 (Fri, 03 Aug 2007)
New Revision: 12895

Modified:
   trunk/HibernateExt/search/doc/reference/en/modules/getting-started.xml
Log:
Work in progress

Modified: trunk/HibernateExt/search/doc/reference/en/modules/getting-started.xml
===================================================================
--- trunk/HibernateExt/search/doc/reference/en/modules/getting-started.xml	2007-08-03 13:48:06 UTC (rev 12894)
+++ trunk/HibernateExt/search/doc/reference/en/modules/getting-started.xml	2007-08-03 14:31:01 UTC (rev 12895)
@@ -8,7 +8,8 @@
 	<para>
 		The following chapter will guide you through the minimal steps
 		required to integrate Hibernate Search into an existing
-		application.
+		Hibernate enabled application. In case you are a Hibernate new timer
+		we recommend you start <ulink url="http://hibernate.org/152.html">here</ulink>.
 	</para>
 
 	<section>
@@ -41,15 +42,80 @@
 				</tbody>
 			</tgroup>
 		</table>
-		
+		<para>
 		You can download the dependencies from the Hibernate 
 		<ulink url="http://www.hibernate.org/6.html">download site</ulink>. The required dependency versions
 		can also be found in the <ulink url="http://www.hibernate.org/6.html#A3">Compatibility Matrix</ulink>.
+		</para>
 	</section>
 
 	<section>
 		<title>Hibernate Configuration</title>
+		Lets assume that your application contains a class <classname>Book</classname> which
+		is managed by Hibernate. You now want to add free text search abilities to your application 
+		in order to search within the books body and summary.
+		<programlisting>
+...
+ at Entity
+public class Book {
+
+	private Integer id;	
+	private String body;	
+	private String summary;	
+	private Set&lt;Author&gt; authors = new HashSet&lt;Author&gt;();
+	private Author mainAuthor;
+	private Date publicationDate;
+	
+	public Book() {
+	}	
+	
+	// standard getters/setters follow here
+...	
+		</programlisting>	
+		<para>
+		Once you have downloaded and added all required dependencies to your application you have 
+		to add some basic Hibernate Search properties to your hibernate configuration file. 
+		We recommend to start your first experiments with a <classname>FSDirectoryProvider</classname>.
+		This has the advantage that you can physically inspect (eg  with 
+		<ulink url="http://www.getopt.org/luke/">Luke</ulink>) the Lucene indeces created by 
+		Hibnerate Search. Once you have a working configuration you can start experimenting with
+		other <xref linkend="search-configuration-directory"/>s.
+		</para>
+		
+		<para>
+		</para>
+		
+		<programlisting>
+...
+# the default base directory for the indecies
+hibernate.search.default.indexBase = /var/lucene/indices		
+
+# the default directory provider
+hibernate.search.default.directory_provider = org.hibernate.search.store.FSDirectoryProvider
+...
+		</programlisting>
+		
 	</section>
+	
+	<section>
+		<title>Indexing</title>
+		<para>
+		Once you have added these properties to your configuration you will have to trigger an
+		initial batch index of your books. You can achieve this by adding the following lines 
+		to your code:
+		</para>
+		<programlisting>
+FullTextSession fullTextSession = Search.createFullTextSession(session);
+Transaction tx = fullTextSession.beginTransaction();
+for (Book book : books) {
+    fullTextSession.index(book);
+}
+tx.commit(); //index are written at commit time    		
+		</programlisting>
+		<para>
+		For more information see <xref linkend="search-batchindex"/>.
+		</para>
+	</section>	
 
 	<section>
 		<title>First search</title>




More information about the hibernate-commits mailing list