Package org.dlese.dpc.schemedit
Class SearchHelper
java.lang.Object
org.dlese.dpc.schemedit.SearchHelper
Class to perform searches and cache the results as well as the query and
sort information. Used to provide access to search results from different
JSP pages (e.g., search, view).
- Author:
- Jonathan Ostwald
-
Constructor Summary
ConstructorsConstructorDescriptionSearchHelper(SimpleLuceneIndex index) Constructor for the SearchHelper object -
Method Summary
Modifier and TypeMethodDescriptionintGets the cachedRecIndex attribute of the SearchHelper objectgets the Cached current record idintReturn the index of the current record in the searchResultsgetHits()Returns all the searchResultsgetHits(int start, int length) Returns a range of searchResultsintgetIndexOf(String recId) gets the index in the searchResults for the record having provided id.booleanConvienence caller of isEmpty for jsp pages.intGets the number of searchResult itemsgetRecId(int recIndex) Gets the id of the result at specifiec index of search results.getResultDoc(String id) Gets the ResultDoc for given record id from the index, returning null if a result is not found.Returns the current searchResults, doing a fresh search and sort if the index has changed since the searchResults were calculated.booleanisEmpty()Returns true if there are no searchResultssearch(org.apache.lucene.search.Query query) Return the results of search with the provided query, performing new search only if a new query string is provided or if the index has changed since the last search.Description of the MethodvoidsetCachedRecIndex(int i) Sets the cachedRecIndex attribute of the SearchHelper objectvoidSets the currentRecId attribute of the RecordList objectvoidsetResults(ResultDoc resultDoc) Sets the results to the single resultDoc provided
-
Constructor Details
-
SearchHelper
Constructor for the SearchHelper object- Parameters:
index- NOT YET DOCUMENTED
-
-
Method Details
-
getResults
Returns the current searchResults, doing a fresh search and sort if the index has changed since the searchResults were calculated.When do we FORCE a new search?? - during sort (where the sort may have changed, but the index has not, so search would not have otherwise have been performed. NOTE: we could also force search by reseting the lastIndexMod to -1!
RETHINK this logic. why cache anything? why not just return the searchResults or an empty list??
- Returns:
- The results value
-
search
Return the results of search with the provided query, performing new search only if a new query string is provided or if the index has changed since the last search.- Parameters:
query- the lucene Query- Returns:
- search results
-
search
Description of the Method- Parameters:
query- Description of the ParametersortObj- Description of the Parameter- Returns:
- Description of the Return Value
-
getHits
Returns all the searchResults- Returns:
- The hits value
-
getHits
Returns a range of searchResults- Parameters:
start- beginning indexlength- length of range- Returns:
- List of records from specified starting index
-
getIndexOf
gets the index in the searchResults for the record having provided id.- Parameters:
recId- a record id- Returns:
- the index, or -1 if no record is found
-
isEmpty
public boolean isEmpty()Returns true if there are no searchResults- Returns:
- The empty value
-
getIsEmpty
public boolean getIsEmpty()Convienence caller of isEmpty for jsp pages.- Returns:
- returns true if there are no search results.
-
getNumHits
public int getNumHits()Gets the number of searchResult items- Returns:
- The numHits value
-
getCurrentRecId
gets the Cached current record id- Returns:
- The currentRecId value
-
setCurrentRecId
Sets the currentRecId attribute of the RecordList object- Parameters:
id- The new currentRecId value
-
getRecId
Gets the id of the result at specifiec index of search results.- Parameters:
recIndex- index into search results- Returns:
- the id or null if not found
-
getCurrentRecIndex
public int getCurrentRecIndex()Return the index of the current record in the searchResults- Returns:
- The currentRecIndex value
-
getCachedRecIndex
public int getCachedRecIndex()Gets the cachedRecIndex attribute of the SearchHelper object- Returns:
- The cachedRecIndex value
-
setCachedRecIndex
public void setCachedRecIndex(int i) Sets the cachedRecIndex attribute of the SearchHelper object- Parameters:
i- The new cachedRecIndex value
-
setResults
Sets the results to the single resultDoc provided- Parameters:
resultDoc- The new results value
-
getResultDoc
Gets the ResultDoc for given record id from the index, returning null if a result is not found.If more than one result is found (this should not happen), print a message and return the first result.
- Parameters:
id- record ID- Returns:
- The resultDoc value or null if resultDoc is not found.
-