okapi.util
Class OkapiSearchUtils

java.lang.Object
  extended by okapi.util.OkapiSearchUtils

public class OkapiSearchUtils
extends java.lang.Object

Search utilities

Version:
$Revision: 31044 $, $Date: 2008-09-02 17:08:01 -0400 (Tue, 02 Sep 2008) $
Author:
MIT Stellar team

Nested Class Summary
static class OkapiSearchUtils.Searcher
          class Searcher Class to perform searching and incremental index updates.
static class OkapiSearchUtils.SearchIndexer
          class SearchIndexer Class to perform indexing.
static class OkapiSearchUtils.SearchResult
          class SearchResult Class to hold a single search result.
 
Constructor Summary
OkapiSearchUtils()
           
 
Method Summary
static boolean doesIndexExist()
          doesIndexExist Checks whether index exists.
static boolean doesIndexRootDirectoryExist()
          doesIndexRootDirectoryExist Checks whether the root index directory exists.
static OkapiSearchUtils.Searcher getSearcher()
          getSearcher Creates and returns a Searcher.
static OkapiSearchUtils.SearchIndexer getSearchIndexer()
          getSearchIndexer Creates and returns a SearchIndexer, if one has not already been given out.
static boolean isIndexingInProgress()
          isIndexingInProgress Checks whether indexing is going on right now.
static void releaseSearcher(OkapiSearchUtils.Searcher s)
          releaseSearcher Returns a Searcher after use.
static void releaseSearchIndexer(OkapiSearchUtils.SearchIndexer si)
          releaseSearchIndexer Returns a SearchIndexer after use.
static void setIndexParameters(java.lang.String rootPath, int pagesPerPDF, int termsPerField)
          setIndexParameters Sets index paths, jpedal path, and other search parameters.
static void setIndexParametersFromContext(javax.servlet.ServletContext context)
          setIndexParametersFromContext Gets parameters from web.xml and stores them in static variables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OkapiSearchUtils

public OkapiSearchUtils()
Method Detail

setIndexParametersFromContext

public static void setIndexParametersFromContext(javax.servlet.ServletContext context)
setIndexParametersFromContext Gets parameters from web.xml and stores them in static variables. Also record the path where the index should be, and the path where new indexes are created. Needs to be called before any other methods. In theory it could just be called once, when the application first loads and a context is first available, but in practice it's easier to call it on every request.

Parameters:
context - servlet context

setIndexParameters

public static void setIndexParameters(java.lang.String rootPath,
                                      int pagesPerPDF,
                                      int termsPerField)
setIndexParameters Sets index paths, jpedal path, and other search parameters. Needs to be called before any other methods. In theory it could just be called once, when the application first loads, but in practice it's easier to call it on every request.

Parameters:
rootPath - path to root index directory
pagesPerPDF - number of pages to index per PDF file (-1 to use default)
termsPerField - number of terms per field to index (-1 to use default)

doesIndexRootDirectoryExist

public static boolean doesIndexRootDirectoryExist()
doesIndexRootDirectoryExist Checks whether the root index directory exists.

Returns:
true if root index directory exists, false otherwise

doesIndexExist

public static boolean doesIndexExist()
doesIndexExist Checks whether index exists.

Returns:
true if index exists, false otherwise

isIndexingInProgress

public static boolean isIndexingInProgress()
isIndexingInProgress Checks whether indexing is going on right now.

Returns:
true if indexing is in progress

getSearchIndexer

public static OkapiSearchUtils.SearchIndexer getSearchIndexer()
getSearchIndexer Creates and returns a SearchIndexer, if one has not already been given out. The SearchIndexer must evenually be returned with releaseSearchIndexer(), either by the caller or by the run() method of the SearchIndexer.

Returns:
new SearchIndexer, or null if one is already out

releaseSearchIndexer

public static void releaseSearchIndexer(OkapiSearchUtils.SearchIndexer si)
releaseSearchIndexer Returns a SearchIndexer after use. The returned object is not checked, though; any non-null object will work.


getSearcher

public static OkapiSearchUtils.Searcher getSearcher()
getSearcher Creates and returns a Searcher. The Searcher must evenually be returned with releaseSearcher(). A searcher is only returned if the index exists, and no index installation is currently pending.

Returns:
new Searcher, or null if one cannot be provided

releaseSearcher

public static void releaseSearcher(OkapiSearchUtils.Searcher s)
releaseSearcher Returns a Searcher after use. The returned object is not checked, though; any non-null object will work. It should not be used once released.



Copyright ? 2001-2009 MIT. All Rights Reserved.