com.arsdigita.search
Class Search

java.lang.Object
  extended bycom.arsdigita.search.Search

public class Search
extends Object

The Search class provides an application level API for querying search indexes. It implements transparent caching of search results across requests for performance. Applications would typically present a form to the user allowing them to enter a query specification. They would then invoke the process method to obtain a (optionally cached) document result set. For here the getResults method enables easy pagination of documents. An example interaction may look like:

   QuerySpecification querySpec = getQuerySpec(request);
   ResultSet results = Search.process(querySpec);
 
   int pageNum = request.getParameter("pageNum");
   Iterator onePage = results.getResults(pageNum*PAGE_SIZE, PAGE_SIZE);
   while (onePage.hasNext()) {
     Document doc = (Document)onePage.next();
     ... do something with doc ...
   }
 


Field Summary
static int CACHE_DOCUMENT_COUNT
          The default search result cache size
static long CACHE_LIFETIME
          The default search result cache lifetime, in milliseconds
static long CACHE_SIZE
          The default search result cache size
static ResultCache DEFAULT_RESULT_CACHE
           
static ResultSet EMPTY_RESULT_SET
          A document result set containing no results
static String INDEXER_INTERMEDIA
          Deprecated. use IndexerType.INTERMEDIA.getKey()
static String INDEXER_LUCENE
          Deprecated. use IndexerType.LUCENE.getKey()
static ResultCache NOP_RESULT_CACHE
          A result cache which doesn't do any caching
static org.apache.log4j.Logger s_log
           
static String XML_NS
          Constant for search XML namespace URL
static String XML_PREFIX
          Constant for serach XML namespace prefix
 
Constructor Summary
Search()
           
 
Method Summary
static SearchConfig getConfig()
          Retrieves the current serach configuration
static Element newElement(String name)
          Creates a new element in the search XML namespace, prepending the default search namespace prefix.
static ResultSet process(QuerySpecification spec)
          Processes a query specification, returning a cached document result set.
static ResultSet process(QuerySpecification spec, ResultCache cache)
          Processes a query specification, returning a cached document result set.
static ResultSet process(QuerySpecification spec, ResultCache cache, String engine)
          Processes a query specification, returning a cached document result set.
static ResultSet processInternal(QuerySpecification spec, String engine)
          Processes a query specification, returning a document result set with no caching.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_log

public static final org.apache.log4j.Logger s_log

EMPTY_RESULT_SET

public static final ResultSet EMPTY_RESULT_SET
A document result set containing no results


CACHE_LIFETIME

public static final long CACHE_LIFETIME
The default search result cache lifetime, in milliseconds

See Also:
Constant Field Values

CACHE_SIZE

public static final long CACHE_SIZE
The default search result cache size

See Also:
Constant Field Values

CACHE_DOCUMENT_COUNT

public static final int CACHE_DOCUMENT_COUNT
The default search result cache size

See Also:
Constant Field Values

NOP_RESULT_CACHE

public static final ResultCache NOP_RESULT_CACHE
A result cache which doesn't do any caching


DEFAULT_RESULT_CACHE

public static final ResultCache DEFAULT_RESULT_CACHE

INDEXER_INTERMEDIA

public static final String INDEXER_INTERMEDIA
Deprecated. use IndexerType.INTERMEDIA.getKey()

Constant for intermedia search indexer


INDEXER_LUCENE

public static final String INDEXER_LUCENE
Deprecated. use IndexerType.LUCENE.getKey()

Constant for lucene search indexer


XML_PREFIX

public static final String XML_PREFIX
Constant for serach XML namespace prefix

See Also:
Constant Field Values

XML_NS

public static final String XML_NS
Constant for search XML namespace URL

See Also:
Constant Field Values
Constructor Detail

Search

public Search()
Method Detail

getConfig

public static SearchConfig getConfig()
Retrieves the current serach configuration


process

public static ResultSet process(QuerySpecification spec)
Processes a query specification, returning a cached document result set. The query is processed using the currently configured query engine.

Parameters:
spec - the query specification
Returns:
cached search result set

process

public static ResultSet process(QuerySpecification spec,
                                ResultCache cache)
Processes a query specification, returning a cached document result set. The query is processed using the currently configured query engine.

Parameters:
spec - the query specification
cache - the result cache to use
Returns:
cached search result set

process

public static ResultSet process(QuerySpecification spec,
                                ResultCache cache,
                                String engine)
Processes a query specification, returning a cached document result set. The query is processed using the requested query engine.

Parameters:
spec - the query specification
cache - the result cache to use
engine - the query engine to use
Returns:
cached search result set

processInternal

public static ResultSet processInternal(QuerySpecification spec,
                                        String engine)
Processes a query specification, returning a document result set with no caching. The query is processed using the requested query engine. Applications should generally use one of the process methods which allows caching of result sets for greater performance.

Parameters:
spec - the query specification
engine - the query engine to use
Returns:
search result set

newElement

public static Element newElement(String name)
Creates a new element in the search XML namespace, prepending the default search namespace prefix. So, calling newElement('foo'), creates an element with a name 'search:foo', where 'search:' is bound to the namespace 'http://rhea.redhat.com/search/1.0'



Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC