de.nava.informa.search
Class ChannelSearcher

java.lang.Object
  extended by de.nava.informa.search.ChannelSearcher

public class ChannelSearcher
extends Object

PUBLIC: Utility class for executing searches against the full-text index that does allow to directly obtain the found news items.

Author:
Niko Schmuck (niko@nava.de)

Field Summary
static int DEFAULT_MAX_RESULTS
          The default maximum number of search results that should be returned by the query.
 
Constructor Summary
ChannelSearcher(String indexDir)
          Constructor which allows to specify the index directory.
 
Method Summary
 String getIndexDir()
           
 int getNrOfHits()
          Returns the number of news items found from the previous full-text search query.
 List<ItemResult> search(ChannelGroupIF channels, String queryString)
          Performs a query on the full-text index using the field ItemFieldConstants.TITLE_AND_DESC as the default search field limited to DEFAULT_MAX_RESULTS number of search results.
 List<ItemResult> search(ChannelGroupIF channels, String queryString, int maxResults)
          Performs a query on the full-text index using the field ItemFieldConstants.TITLE_AND_DESC as the default search field.
 void setIndexDir(String indexDir)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_RESULTS

public static final int DEFAULT_MAX_RESULTS
The default maximum number of search results that should be returned by the query.

See Also:
Constant Field Values
Constructor Detail

ChannelSearcher

public ChannelSearcher(String indexDir)
                throws IOException
Constructor which allows to specify the index directory. For searching the full-text index the lucene StandardAnalyzer is used.

Parameters:
indexDir - - The directory from which the index can be retrieved.
Throws:
IOException
Method Detail

search

public List<ItemResult> search(ChannelGroupIF channels,
                               String queryString)
                        throws QueryParseException,
                               IOException
Performs a query on the full-text index using the field ItemFieldConstants.TITLE_AND_DESC as the default search field limited to DEFAULT_MAX_RESULTS number of search results.

Returns:
A List of ItemResult objects ordered by relevance.
Throws:
QueryParseException
IOException

search

public List<ItemResult> search(ChannelGroupIF channels,
                               String queryString,
                               int maxResults)
                        throws QueryParseException,
                               IOException
Performs a query on the full-text index using the field ItemFieldConstants.TITLE_AND_DESC as the default search field.

Returns:
A List of ItemResult objects ordered by relevance.
Throws:
QueryParseException
IOException

getNrOfHits

public int getNrOfHits()
Returns the number of news items found from the previous full-text search query. Note: Use only directly after the search was performed, otherwise the return value may be wrong.


setIndexDir

public void setIndexDir(String indexDir)

getIndexDir

public String getIndexDir()


Copyright © 2002-2007 Niko Schmuck. All Rights Reserved.