Lucene: A Tutorial Introduction to Full-Text Indexing in Java
Lucene is a powerful and elegant library for full-text indexing and searching in Java. In this article, we go through some Lucene basics, by adding simple yet powerful full-text index and search functions to a typical J2EE web application.
Nowadays, any modern web site worth its salt is considered to need a "Google-like" search function. Complex multi-criteria search screens are often perceived by users as being too complex, and are in fact rarely used. Users want to be able to just type the word(s) they’re seeking and have the computer do the rest. This explains the growing popularity of search engines such as those of Yahoo! and Google and, more recently, tools such as Google Desktop.
If you need to add this sort of rich full-text search functionality to your Java web application, look no further! Lucene is an extremely rich and powerful full-text search API written in Java. You can use Lucene to provide consistent full-text indexing across both database objects and documents in various formats (Microsoft Office documents, PDF, HTML, text, and so on).
In this article, we’ll go through the basics of using Lucene to add full-text search functionality to a fairly typical J2EE application—an online accommodation database. The main business object is the Hotel class. In this tutorial, a Hotel has a unique identifier, a name, a city, and a description.