org.apache.cocoon.components.search
Class SimpleLuceneCocoonSearcherImpl

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.components.search.SimpleLuceneCocoonSearcherImpl
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.logger.Loggable, LuceneCocoonSearcher, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable

public class SimpleLuceneCocoonSearcherImpl
extends org.apache.avalon.framework.logger.AbstractLoggable
implements LuceneCocoonSearcher, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.excalibur.pool.Recyclable

This class provides searching via lucene.

In order to do searching you need a lucene Directory where the lucene generated index resides. Moreover you must know the lucene Analyzer which has been used for indexing, and which will be used for searching.

Knowing this you can may start searching having a query which is parsable by an QueryParser, and having the name of the default field to use in searching.

This class returns an Hit object as its search result.

Version:
CVS $Id: SimpleLuceneCocoonSearcherImpl.java,v 1.5 2002/02/22 07:00:12 cziegeler Exp $
Author:
Bernhard Huber

Field Summary
protected static java.lang.String ANALYZER_CLASSNAME_CONFIG
          Configuration element name of lucene's Analyzer class.
protected static java.lang.String ANALYZER_CLASSNAME_DEFAULT
          Configuration element default value of lucene's Analyzer class.
protected static java.lang.String DEFAULT_QUERY_CONFIG
          Configuration element name of default-query.
protected static java.lang.String DEFAULT_QUERY_DEFAULT
          Configuration element default value of default-query.
protected static java.lang.String DEFAULT_SEARCH_FIELD_CONFIG
          Configuration element name of default search field.
protected static java.lang.String DEFAULT_SEARCH_FIELD_DEFAULT
          Configuration element default value of lucene's default search field.
protected static java.lang.String DIRECTORY_CONFIG
          Configuration element name of lucene's default filesystem default directory.
protected static java.lang.String DIRECTORY_DEFAULT
          Configuration element default value of filesystem default directory.
protected  org.apache.avalon.framework.component.ComponentManager manager
          The component manager instance
protected static java.lang.String QUERYPARSER_CLASSNAME_CONFIG
          Configuration element name of query parser class name.
protected static java.lang.String QUERYPARSER_CLASSNAME_DEFAULT
          Configuration element default value of queryparser-classname.
 
Fields inherited from interface org.apache.cocoon.components.search.LuceneCocoonSearcher
ROLE
 
Constructor Summary
SimpleLuceneCocoonSearcherImpl()
           
 
Method Summary
 void compose(org.apache.avalon.framework.component.ComponentManager manager)
          Set the current ComponentManager instance used by this Composable.
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
          configure
 void dispose()
          Description of the Method
 org.apache.lucene.index.IndexReader getReader()
          Get an IndexReader.
 void recycle()
          Description of the Method
 org.apache.lucene.search.Hits search(java.lang.String query_string, java.lang.String default_field)
          Description of the Method
 void setAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
          set an analyzer, overriding the analyzerClassnameDefault.
 void setDirectory(org.apache.lucene.store.Directory directory)
          Sets the directory attribute of the SimpleLuceneCocoonSearcherImpl object
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANALYZER_CLASSNAME_CONFIG

protected static final java.lang.String ANALYZER_CLASSNAME_CONFIG
Configuration element name of lucene's Analyzer class.

Its value is analyzer-classname.

Since:
 

ANALYZER_CLASSNAME_DEFAULT

protected static final java.lang.String ANALYZER_CLASSNAME_DEFAULT
Configuration element default value of lucene's Analyzer class.

Its value is, org.apache.lucene.analysis.standard.StandardAnalyzer.

Since:
 

DEFAULT_SEARCH_FIELD_CONFIG

protected static final java.lang.String DEFAULT_SEARCH_FIELD_CONFIG
Configuration element name of default search field.

Its value is default-seach-field.

Since:
 

DEFAULT_SEARCH_FIELD_DEFAULT

protected static final java.lang.String DEFAULT_SEARCH_FIELD_DEFAULT
Configuration element default value of lucene's default search field.

Its value is body.

Since:
 

DEFAULT_QUERY_CONFIG

protected static final java.lang.String DEFAULT_QUERY_CONFIG
Configuration element name of default-query.

Its value is default-query.

Since:
 

DEFAULT_QUERY_DEFAULT

protected static final java.lang.String DEFAULT_QUERY_DEFAULT
Configuration element default value of default-query.

Its value is null.

Since:
 

QUERYPARSER_CLASSNAME_CONFIG

protected static final java.lang.String QUERYPARSER_CLASSNAME_CONFIG
Configuration element name of query parser class name.

Its value is queryparser-classname.

Since:
 

QUERYPARSER_CLASSNAME_DEFAULT

protected static final java.lang.String QUERYPARSER_CLASSNAME_DEFAULT
Configuration element default value of queryparser-classname.

Its value is org.apache.lucene.queryParser.QueryParser.

Since:
 

DIRECTORY_CONFIG

protected static final java.lang.String DIRECTORY_CONFIG
Configuration element name of lucene's default filesystem default directory.

Its value is directory.

Since:
 

DIRECTORY_DEFAULT

protected static final java.lang.String DIRECTORY_DEFAULT
Configuration element default value of filesystem default directory.

Its value is null.

Since:
 

manager

protected org.apache.avalon.framework.component.ComponentManager manager
The component manager instance
Since:
 
Constructor Detail

SimpleLuceneCocoonSearcherImpl

public SimpleLuceneCocoonSearcherImpl()
Method Detail

setAnalyzer

public void setAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
set an analyzer, overriding the analyzerClassnameDefault.
Specified by:
setAnalyzer in interface LuceneCocoonSearcher
Parameters:
analyzer - The new analyzer value
Since:
 

setDirectory

public void setDirectory(org.apache.lucene.store.Directory directory)
Sets the directory attribute of the SimpleLuceneCocoonSearcherImpl object
Specified by:
setDirectory in interface LuceneCocoonSearcher
Parameters:
directory - The new directory value
Since:
 

getReader

public org.apache.lucene.index.IndexReader getReader()
                                              throws java.io.IOException
Get an IndexReader.

As an IndexReader might be cached, it is check if the indexReader is still valid.

Returns:
IndexReader an up to date indexReader
Throws:
java.io.IOException - Description of Exception
Since:
 

configure

public void configure(org.apache.avalon.framework.configuration.Configuration conf)
               throws org.apache.avalon.framework.configuration.ConfigurationException
configure
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Parameters:
conf - Description of Parameter
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - Description of Exception
Since:
 

compose

public void compose(org.apache.avalon.framework.component.ComponentManager manager)
             throws org.apache.avalon.framework.component.ComponentException
Set the current ComponentManager instance used by this Composable.
Specified by:
compose in interface org.apache.avalon.framework.component.Composable
Parameters:
manager - Description of Parameter
Throws:
org.apache.avalon.framework.component.ComponentException - Description of Exception
Since:
 

dispose

public void dispose()
Description of the Method
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable
Since:
 

recycle

public void recycle()
Description of the Method
Specified by:
recycle in interface org.apache.avalon.excalibur.pool.Recyclable
Since:
 

search

public org.apache.lucene.search.Hits search(java.lang.String query_string,
                                            java.lang.String default_field)
                                     throws ProcessingException
Description of the Method
Specified by:
search in interface LuceneCocoonSearcher
Parameters:
query_string - Description of Parameter
default_field - Description of Parameter
Returns:
Description of the Returned Value
Throws:
ProcessingException - Description of Exception
Since:
 


Copyright � 1999-2002 Apache Software Foundation. All Rights Reserved.