}
if( searchQuery.equals(currentSearchQuery) && cachedResults != null ) // same query
return cachedResults;
SearchResult result = null;
cachedResults = null;
resultCount = 0;
Object[] resultArray = null;
if(searchString != null)
{
try {
result = searcher.search(searchQuery); // do the search
currentSearchQuery = searchQuery;
if( result == null ) {
if( !searchQuery.isFuzzy() ) {
SearchQuery newQuery = new SearchQuery(searchQuery);
newQuery.setExact(false);
newQuery.setFuzzy(true);
resultArray = new Object[]{NO_RESULTS_MESSAGE, newQuery}; // add fuzzy query
} else {
resultArray = new Object[]{NO_RESULTS_MESSAGE};
}
cachedResults = resultArray;
return resultArray;
}
searchTerms = result.getSearchTerms();
} catch (Exception e) {
InstaSearchPlugin.log(e);
return new Exception[]{e};
}
}
List<SearchResultDoc> resultDocs = result.getResultDocs();
this.resultCount = resultDocs.size();
boolean addMoreResults = false, addFindSimilar = false;
if( searchQuery.isLimited() && result.isFull() ) { // if only showing limited number of matches
addMoreResults = true;
}
else
{
if( searchQuery.isExact() && !searchQuery.isFuzzy() ) // if query is exact, can try search for individual tokens