edu.mayo.informatics.indexer.lucene
Class LuceneIndexSearcher

java.lang.Object
  extended by edu.mayo.informatics.indexer.lucene.LuceneIndexSearcher
All Implemented Interfaces:
SearchServiceInterface

public class LuceneIndexSearcher
extends java.lang.Object
implements SearchServiceInterface

Used for searching 1 index. This is the main class to be used for searching. It automatically searches across multiple indexes, and automatically re-opens the indexes as necessary if they have become out of date (due to another process adding documents to the index)

Author:
Dan Armbrust

Constructor Summary
LuceneIndexSearcher(LuceneIndexReader index)
           
 
Method Summary
 void close()
          Close.
 org.apache.lucene.search.Explanation explain(org.apache.lucene.search.Query query, int doc)
          Explain.
 int getHitTotal()
          Gets the hit total.
 org.apache.lucene.document.Document[] getNextSearchResults(int howMany)
          Gets the next search results.
 float[] getScores()
          Returned the scores for that last retrieved set of results.
 org.apache.lucene.search.Similarity getSimilarity()
          Gets the similarity.
 boolean hasMoreHits()
          Checks for more hits.
 void reloadSearcher()
           
 org.apache.lucene.document.Document[] search(org.apache.lucene.search.Query query, org.apache.lucene.search.Filter filter, boolean skipLowScoringHits, int maxToReturn)
          Search.
 void search(org.apache.lucene.search.Query query, org.apache.lucene.search.Filter filter, org.apache.lucene.search.HitCollector hitCollector)
          Search.
 java.lang.String[] searchableFields()
          Searchable fields.
 void setSimilarity(org.apache.lucene.search.Similarity similarity)
          Sets the similarity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LuceneIndexSearcher

public LuceneIndexSearcher(LuceneIndexReader index)
Method Detail

reloadSearcher

public void reloadSearcher()
                    throws InternalIndexerErrorException
Throws:
InternalIndexerErrorException

search

public org.apache.lucene.document.Document[] search(org.apache.lucene.search.Query query,
                                                    org.apache.lucene.search.Filter filter,
                                                    boolean skipLowScoringHits,
                                                    int maxToReturn)
                                             throws InternalIndexerErrorException
Description copied from interface: SearchServiceInterface
Search.

Specified by:
search in interface SearchServiceInterface
Parameters:
query - the query
filter - the filter
skipLowScoringHits - the skip low scoring
maxToReturn - the max to return
Returns:
the document[]
Throws:
InternalIndexerErrorException - the internal indexer error exception

search

public void search(org.apache.lucene.search.Query query,
                   org.apache.lucene.search.Filter filter,
                   org.apache.lucene.search.HitCollector hitCollector)
            throws InternalIndexerErrorException,
                   IndexSearchException
Description copied from interface: SearchServiceInterface
Search.

Specified by:
search in interface SearchServiceInterface
Parameters:
query - the query
filter - the filter
hitCollector - the hit collector
Throws:
InternalIndexerErrorException - the internal indexer error exception
IndexSearchException

getNextSearchResults

public org.apache.lucene.document.Document[] getNextSearchResults(int howMany)
                                                           throws InternalIndexerErrorException
Description copied from interface: SearchServiceInterface
Gets the next search results.

Specified by:
getNextSearchResults in interface SearchServiceInterface
Parameters:
howMany - the how many
Returns:
the next search results
Throws:
InternalIndexerErrorException - the internal indexer error exception

hasMoreHits

public boolean hasMoreHits()
Description copied from interface: SearchServiceInterface
Checks for more hits.

Specified by:
hasMoreHits in interface SearchServiceInterface
Returns:
true, if successful

getScores

public float[] getScores()
                  throws InternalIndexerErrorException
Returned the scores for that last retrieved set of results.

Specified by:
getScores in interface SearchServiceInterface
Returns:
An array of scores that match the hits.
Throws:
InternalIndexerErrorException

getHitTotal

public int getHitTotal()
Description copied from interface: SearchServiceInterface
Gets the hit total.

Specified by:
getHitTotal in interface SearchServiceInterface
Returns:
the hit total

searchableFields

public java.lang.String[] searchableFields()
Description copied from interface: SearchServiceInterface
Searchable fields.

Specified by:
searchableFields in interface SearchServiceInterface
Returns:
the string[]

explain

public org.apache.lucene.search.Explanation explain(org.apache.lucene.search.Query query,
                                                    int doc)
                                             throws InternalIndexerErrorException
Description copied from interface: SearchServiceInterface
Explain.

Specified by:
explain in interface SearchServiceInterface
Parameters:
query - the query
doc - the doc
Returns:
the explanation
Throws:
InternalIndexerErrorException - the internal indexer error exception

setSimilarity

public void setSimilarity(org.apache.lucene.search.Similarity similarity)
                   throws InternalIndexerErrorException
Description copied from interface: SearchServiceInterface
Sets the similarity.

Specified by:
setSimilarity in interface SearchServiceInterface
Parameters:
similarity - the new similarity
Throws:
InternalIndexerErrorException - the internal indexer error exception

getSimilarity

public org.apache.lucene.search.Similarity getSimilarity()
Description copied from interface: SearchServiceInterface
Gets the similarity.

Specified by:
getSimilarity in interface SearchServiceInterface
Returns:
the similarity

close

public void close()
           throws InternalIndexerErrorException
Description copied from interface: SearchServiceInterface
Close.

Specified by:
close in interface SearchServiceInterface
Throws:
InternalIndexerErrorException - the internal indexer error exception

Copyright: (c) 2004-2006 Mayo Foundation for Medical Education and Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the triple-shield Mayo logo are trademarks and service marks of MFMER.