org.apache.commons.scaffold.lucene
Class Engine

java.lang.Object
  extended by org.apache.commons.scaffold.lucene.Engine

public final class Engine
extends Object

Search engine methods for Lucene.

Version:
$Revision: 155464 $ $Date: 2005-02-26 13:26:54 +0000 (Sat, 26 Feb 2005) $
Author:
Ted Husted

Constructor Summary
Engine()
           
 
Method Summary
static String blankNull(String string)
          Convenience method to use an empty string in place of a null for indexing.
static int deleteTerm(org.apache.lucene.index.Term term)
          Delete record matching term from default index.
static org.apache.lucene.analysis.Analyzer getAnalyzer()
          Return default analyzer for application A non-English site should use a different analyzer
static org.apache.lucene.search.Hits getHits(org.apache.lucene.search.Query query)
          Return hits for model using default searcher.
static String getIndexPath()
          Return path for index.
static org.apache.lucene.index.IndexReader getIndexReader()
          Return default reader for application.
static org.apache.lucene.index.IndexWriter getIndexWriter(boolean create)
          Return default writer for application.
static org.apache.lucene.search.Query getQuery(String value, String field)
          Return hits for value and field
static org.apache.lucene.search.Searcher getSearcher()
          Return default searcher for application.
static void init(String _indexPath)
          Set path for index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Engine

public Engine()
Method Detail

getIndexPath

public static String getIndexPath()
Return path for index.


init

public static void init(String _indexPath)
Set path for index. MUST be set at startup before using other methods.


blankNull

public static final String blankNull(String string)
Convenience method to use an empty string in place of a null for indexing.

Parameters:
string - The string to test for null
Returns:
A blank String [BLANK_STRING] if string is null

getAnalyzer

public static final org.apache.lucene.analysis.Analyzer getAnalyzer()
Return default analyzer for application A non-English site should use a different analyzer

Returns:
The default analyzer
Throws:
Throws - ResourceException on IO error

getSearcher

public static final org.apache.lucene.search.Searcher getSearcher()
                                                           throws ResourceException
Return default searcher for application.

Returns:
default searcher
Throws:
Throws - ResourceException on IO error
ResourceException

getIndexWriter

public static final org.apache.lucene.index.IndexWriter getIndexWriter(boolean create)
                                                                throws ResourceException
Return default writer for application.

Parameters:
Set - to true to create a new index; usually false.
Returns:
default writer
Throws:
Throws - ResourceException on IO error
ResourceException

getIndexReader

public static final org.apache.lucene.index.IndexReader getIndexReader()
                                                                throws ResourceException
Return default reader for application.

Returns:
default reader
Throws:
Throws - ResourceException on IO error
ResourceException

getHits

public static final org.apache.lucene.search.Hits getHits(org.apache.lucene.search.Query query)
                                                   throws ResourceException
Return hits for model using default searcher.

Parameters:
query - The query we are processing
Returns:
hits for model
Throws:
ResourceException

getQuery

public static final org.apache.lucene.search.Query getQuery(String value,
                                                            String field)
                                                     throws ParameterException
Return hits for value and field

Parameters:
value - The term to match ("Smith")
field - The field to patch ("name")
Returns:
hits for model
Throws:
ParameterException

deleteTerm

public static final int deleteTerm(org.apache.lucene.index.Term term)
                            throws ResourceException
Delete record matching term from default index. Access to the index is synchronized.

Parameters:
term - The term matching the entry to delete
Throws:
Throws - ResourceException on IO error
ResourceException


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.