Save This Page
Home » cocoon-2.1.11-src » org.apache » cocoon » components » search » [javadoc | source]
org.apache.cocoon.components.search
public class: SimpleLuceneCocoonSearcherImpl [javadoc | source]
java.lang.Object
   org.apache.avalon.framework.logger.AbstractLogEnabled
      org.apache.cocoon.components.search.SimpleLuceneCocoonSearcherImpl

All Implemented Interfaces:
    org.apache.avalon.framework.activity.Disposable, org.apache.avalon.excalibur.pool.Recyclable, LuceneCocoonSearcher, org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.configuration.Configurable

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.

Nested Class Summary:
static class  SimpleLuceneCocoonSearcherImpl.IndexReaderCache  This class should help to minimise usage of IndexReaders. 
Field Summary
protected static final  String ANALYZER_CLASSNAME_CONFIG    Configuration element name of lucene's Analyzer class.

Its value is analyzer-classname.

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

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

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

Its value is default-seach-field.

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

Its value is body.

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

Its value is default-query.

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

Its value is null.

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

Its value is queryparser-classname.

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

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

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

Its value is directory.

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

Its value is null.

 
protected  ServiceManager manager    The service manager instance 
Method from org.apache.cocoon.components.search.SimpleLuceneCocoonSearcherImpl Summary:
configure,   dispose,   getAnalyzer,   getReader,   recycle,   search,   search,   service,   setAnalyzer,   setDirectory
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.cocoon.components.search.SimpleLuceneCocoonSearcherImpl Detail:
 public  void configure(Configuration conf) throws ConfigurationException 
    configure this component
 public  void dispose() 
    Dispose this component, releasing IndexSearcher, and IndexReaderCache.
 public Analyzer getAnalyzer() 
    get the analyzer.
 public IndexReader getReader() throws IOException 
    Get an IndexReader.

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

 public  void recycle() 
    Recycle this component, releasing IndexSearcher, and IndexReaderCache.
 public Hits search(Query query) throws ProcessingException 
    Search lucene index. This method is designed to be used by other components, or Flowscripts
 public Hits search(String query_string,
    String default_field) throws ProcessingException 
    Search lucene index.
 public  void service(ServiceManager manager) throws ServiceException 
    Set the current ServiceManager instance used by this Serviceable.
 public  void setAnalyzer(Analyzer analyzer) 
    set an analyzer, overriding the analyzerClassnameDefault.
 public  void setDirectory(Directory directory) 
    Sets the directory attribute of the SimpleLuceneCocoonSearcherImpl object