com.atlassian.bonnie.search
Class LuceneSearcher

java.lang.Object
  extended bycom.atlassian.bonnie.search.LuceneSearcher
All Implemented Interfaces:
Searcher

public class LuceneSearcher
extends java.lang.Object
implements Searcher


Constructor Summary
LuceneSearcher()
           
 
Method Summary
 org.apache.lucene.search.Query buildStandardQuery(java.lang.String[] searchFields, java.lang.String query)
          Different from term query in that the query parameter specified is passed through an analyzer that may remove certain stop words before constructing a Query.
 org.apache.lucene.search.Query buildStandardQuery(java.lang.String defaultSearchField, java.lang.String query)
           
 java.lang.String explain(org.apache.lucene.search.Query myquery, int docid)
           
 java.util.List getAllFieldValues(java.lang.String fieldName)
           
 org.apache.lucene.search.Query rewrite(org.apache.lucene.search.Query query)
           
 java.util.List search(org.apache.lucene.search.Query myquery)
          Performs the search operation and returns a List of found items.
 java.util.List search(org.apache.lucene.search.Query myquery, org.apache.lucene.search.Sort sort)
           
 int searchCount(org.apache.lucene.search.Query myquery)
          Run a search, but just give me back the result as a #.
 int searchCount(org.apache.lucene.search.Query query, org.apache.lucene.search.Filter filter)
           
 java.util.List searchForFields(org.apache.lucene.search.Query myquery, java.util.Set fieldsToExtract, int startIndex, int numItems)
          Search an index and return not only the item handles, but also pull arbitrary fields from the document and return them too.
 java.util.List searchForFields(org.apache.lucene.search.Query myquery, java.util.Set fieldsToExtract, int startIndex, int numItems, org.apache.lucene.search.Filter filter, int[] filteredcount)
           
 java.util.List searchForFields(org.apache.lucene.search.Query myquery, java.util.Set fieldsToExtract, int startIndex, int numItems, org.apache.lucene.search.Filter filter, org.apache.lucene.search.Sort sort, int[] filteredcount)
           
 void setBooleanQueryMaxClause(int max)
           
 void setLuceneAnalyzerFactory(LuceneAnalyzerFactory luceneAnalyzerFactory)
           
 void setLuceneConnection(LuceneConnection luceneConnection)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LuceneSearcher

public LuceneSearcher()
Method Detail

setLuceneConnection

public void setLuceneConnection(LuceneConnection luceneConnection)

setLuceneAnalyzerFactory

public void setLuceneAnalyzerFactory(LuceneAnalyzerFactory luceneAnalyzerFactory)

setBooleanQueryMaxClause

public void setBooleanQueryMaxClause(int max)

buildStandardQuery

public org.apache.lucene.search.Query buildStandardQuery(java.lang.String[] searchFields,
                                                         java.lang.String query)
Different from term query in that the query parameter specified is passed through an analyzer that may remove certain stop words before constructing a Query. Desirable for full text search fields. Undesirable for keyword searches (build a Term query instead).

Specified by:
buildStandardQuery in interface Searcher
Parameters:
searchFields -
query -
Returns:
a list of Hit results

buildStandardQuery

public org.apache.lucene.search.Query buildStandardQuery(java.lang.String defaultSearchField,
                                                         java.lang.String query)
Specified by:
buildStandardQuery in interface Searcher

search

public java.util.List search(org.apache.lucene.search.Query myquery)
Description copied from interface: Searcher
Performs the search operation and returns a List of found items.

Specified by:
search in interface Searcher

search

public java.util.List search(org.apache.lucene.search.Query myquery,
                             org.apache.lucene.search.Sort sort)
Specified by:
search in interface Searcher

rewrite

public org.apache.lucene.search.Query rewrite(org.apache.lucene.search.Query query)
Specified by:
rewrite in interface Searcher

explain

public java.lang.String explain(org.apache.lucene.search.Query myquery,
                                int docid)
Specified by:
explain in interface Searcher

searchCount

public int searchCount(org.apache.lucene.search.Query myquery)
Description copied from interface: Searcher
Run a search, but just give me back the result as a #.

Specified by:
searchCount in interface Searcher

searchCount

public int searchCount(org.apache.lucene.search.Query query,
                       org.apache.lucene.search.Filter filter)
Specified by:
searchCount in interface Searcher

searchForFields

public java.util.List searchForFields(org.apache.lucene.search.Query myquery,
                                      java.util.Set fieldsToExtract,
                                      int startIndex,
                                      int numItems)
Description copied from interface: Searcher
Search an index and return not only the item handles, but also pull arbitrary fields from the document and return them too.

Extracting fields from all documents could be expensive and potentially unnecessary, so the startIndex and numItems parameters allow you to control where the extraction will start from, and how many items it will continue for.

Specified by:
searchForFields in interface Searcher
Parameters:
myquery - The query to run
fieldsToExtract - A set of field names which will be extracted from the document and returned - if the fields are null, or the set is empty, BaseDocumentBuilder.FieldName.HANDLE_FIELD_NAME will be used.
startIndex - The index to start extracting content from, or 0 for the start of the list
numItems - The number of items to be extracted in total, or Integer.MAX_VALUE for all items
Returns:
A list containing maps of the fields you wish to extract. For results outside of the startIndex/numItems range, this list will contain null values.

searchForFields

public java.util.List searchForFields(org.apache.lucene.search.Query myquery,
                                      java.util.Set fieldsToExtract,
                                      int startIndex,
                                      int numItems,
                                      org.apache.lucene.search.Filter filter,
                                      int[] filteredcount)
Specified by:
searchForFields in interface Searcher

searchForFields

public java.util.List searchForFields(org.apache.lucene.search.Query myquery,
                                      java.util.Set fieldsToExtract,
                                      int startIndex,
                                      int numItems,
                                      org.apache.lucene.search.Filter filter,
                                      org.apache.lucene.search.Sort sort,
                                      int[] filteredcount)
Specified by:
searchForFields in interface Searcher

getAllFieldValues

public java.util.List getAllFieldValues(java.lang.String fieldName)
Specified by:
getAllFieldValues in interface Searcher


Copyright © 2006-2009 Atlassian Software Systems Pty Ltd. All Rights Reserved.