/** Search with lucene using the previously declared search function */
  private LuceneResult searchView(
      LuceneSearchView function, String queryString, boolean includeDocs) {
    if (isNullOrEmpty(queryString)) {
      return null;
    }

    LuceneQuery query = new LuceneQuery(function.searchView, function.searchFunction);

    query.setQuery(queryString);
    query.setIncludeDocs(includeDocs);
    setQueryLimit(query);

    try {
      return queryLucene(query);
    } catch (DbAccessException e) {
      log.error("Error querying database.", e);
      return null;
    }
  }
 private void setQueryLimit(LuceneQuery query) {
   if (resultLimit > 0) {
     query.setLimit(resultLimit);
   }
 }