|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.logger.AbstractLogEnabled org.apache.cocoon.components.search.SimpleLuceneCocoonSearcherImpl
public class SimpleLuceneCocoonSearcherImpl
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.
Field Summary | |
---|---|
protected static String |
ANALYZER_CLASSNAME_CONFIG
Configuration element name of lucene's Analyzer class. |
protected static String |
ANALYZER_CLASSNAME_DEFAULT
Configuration element default value of lucene's Analyzer class. |
protected static String |
DEFAULT_QUERY_CONFIG
Configuration element name of default-query. |
protected static String |
DEFAULT_QUERY_DEFAULT
Configuration element default value of default-query. |
protected static String |
DEFAULT_SEARCH_FIELD_CONFIG
Configuration element name of default search field. |
protected static String |
DEFAULT_SEARCH_FIELD_DEFAULT
Configuration element default value of lucene's default search field. |
protected static String |
DIRECTORY_CONFIG
Configuration element name of lucene's default filesystem default directory. |
protected static String |
DIRECTORY_DEFAULT
Configuration element default value of filesystem default directory. |
protected ServiceManager |
manager
The service manager instance |
protected static String |
QUERYPARSER_CLASSNAME_CONFIG
Configuration element name of query parser class name. |
protected static 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 |
configure(Configuration conf)
configure this component |
void |
dispose()
Dispose this component, releasing IndexSearcher, and IndexReaderCache. |
org.apache.lucene.analysis.Analyzer |
getAnalyzer()
get the analyzer. |
org.apache.lucene.index.IndexReader |
getReader()
Get an IndexReader. |
void |
recycle()
Recycle this component, releasing IndexSearcher, and IndexReaderCache. |
org.apache.lucene.search.Hits |
search(org.apache.lucene.search.Query query)
Search lucene index. |
org.apache.lucene.search.Hits |
search(String query_string,
String default_field)
Search lucene index. |
void |
service(ServiceManager manager)
Set the current ServiceManager instance used by this
Serviceable . |
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.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String ANALYZER_CLASSNAME_CONFIG
Its value is
analyzer-classname
.
protected static final String ANALYZER_CLASSNAME_DEFAULT
Its value is,
org.apache.lucene.analysis.standard.StandardAnalyzer
.
protected static final String DEFAULT_SEARCH_FIELD_CONFIG
Its value is
default-seach-field
.
protected static final String DEFAULT_SEARCH_FIELD_DEFAULT
Its value is body
.
protected static final String DEFAULT_QUERY_CONFIG
Its value is
default-query
.
protected static final String DEFAULT_QUERY_DEFAULT
Its value is null
.
protected static final String QUERYPARSER_CLASSNAME_CONFIG
Its value is
queryparser-classname
.
protected static final String QUERYPARSER_CLASSNAME_DEFAULT
Its value is
org.apache.lucene.queryParser.QueryParser
.
protected static final String DIRECTORY_CONFIG
Its value is directory
.
protected static final String DIRECTORY_DEFAULT
Its value is null
.
protected ServiceManager manager
Constructor Detail |
---|
public SimpleLuceneCocoonSearcherImpl()
Method Detail |
---|
public void setAnalyzer(org.apache.lucene.analysis.Analyzer analyzer)
setAnalyzer
in interface LuceneCocoonSearcher
analyzer
- The new analyzer valuepublic org.apache.lucene.analysis.Analyzer getAnalyzer()
getAnalyzer
in interface LuceneCocoonSearcher
public void setDirectory(org.apache.lucene.store.Directory directory)
setDirectory
in interface LuceneCocoonSearcher
directory
- The new directory valuepublic org.apache.lucene.index.IndexReader getReader() throws IOException
As an IndexReader might be cached, it is check if the indexReader is still valid.
IOException
- is thrown iff it's impossible to create
an IndexReaderpublic void configure(Configuration conf) throws ConfigurationException
configure
in interface Configurable
conf
- of this component
ConfigurationException
- is thrown iff configuration of
this component failspublic void service(ServiceManager manager) throws ServiceException
ServiceManager
instance used by this
Serviceable
.
service
in interface Serviceable
manager
- manager of this component
ServiceException
- is never thrownpublic void dispose()
dispose
in interface Disposable
public void recycle()
recycle
in interface Recyclable
public org.apache.lucene.search.Hits search(String query_string, String default_field) throws ProcessingException
search
in interface LuceneCocoonSearcher
query_string
- is lucene's query stringdefault_field
- the lucene field to run the query
ProcessingException
- iff its not possible do run the querypublic org.apache.lucene.search.Hits search(org.apache.lucene.search.Query query) throws ProcessingException
search
in interface LuceneCocoonSearcher
query
- the lucene Query
ProcessingException
- if its not possible do run the query
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |