SearchHelper.java revision 1220
1028N/A * The contents of this file are subject to the terms of the 1028N/A * Common Development and Distribution License (the "License"). 1028N/A * You may not use this file except in compliance with the License. 1028N/A * language governing permissions and limitations under the License. 1028N/A * When distributing Covered Code, include this CDDL HEADER in each 1028N/A * If applicable, add the following below this CDDL HEADER, with the 1028N/A * fields enclosed by brackets "[]" replaced with your own identifying 1028N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1028N/A * Copyright (c) 2011 Jens Elkner. 1190N/A * complexity from UI design. 1028N/A /** opengrok's data root: used to find the search index file */ /** context path, i.e. the applications context path (usually /source) to * use when generating a redirect URL */ /** piggyback: if {@code true}, files in opengrok's data directory are /** piggyback: the source root directory. */ /** piggyback: the eftar filereader to use. */ /** the result cursor start index, i.e. where to start displaying results */ /** max. number of result items to show */ /** the QueryBuilder used to create the query */ /** the order to use to ordery query results */ /** if {@code true} a {@link ParallelMultiSearcher} will be used instead of * a {@link MultiSearcher}. */ /** Indicate, whether this is search from a cross reference. If {@code true} * {@link #executeQuery()} sets {@link #redirect} if certain conditions are /** if not {@code null}, the consumer should redirect the client to a * separate result page denoted by the value of this field. Automatically * set via {@link #prepareExec(SortedSet)} and {@link #executeQuery()}. */ /** if not {@code null}, the UI should show this error message and stop * processing the search. Automatically set via {@link #prepareExec(SortedSet)} * and {@link #executeQuery()}.*/ /** the searcher used to open/search the index. Automatically set via * {@link #prepareExec(SortedSet)}. */ /** list of docs which result from the executing the query */ /** total number of hits */ /** the query created by the used {@link QueryBuilder} via * {@link #prepareExec(SortedSet)}. */ /** the lucene sort instruction based on {@link #order} created via * {@link #prepareExec(SortedSet)}. */ /** projects to use to setup indexer searchers. Usually setup via * {@link #prepareExec(SortedSet)}. */ /** opengrok summary context. Usually created via {@link #prepareSummary()}. */ /** result summarizer usually created via {@link #prepareSummary()}. */ /** history context usually created via {@link #prepareSummary()}.*/ /** Default query parse error message prefix */ * Create the searcher to use wrt. to currently set parameters and the given * projects. Does not produce any {@link #redirect} link. It also does * nothing if {@link #redirect} or {@link #errorMsg} have a none-{@code null} * <li>{@link #builder}</li> * <li>{@link #dataRoot}</li> * <li>{@link #order} (falls back to relevance if unset)</li> * <li>{@link #parallel} (default: false)</li> * <li>{@link #query}</li> * <li>{@link #searcher}</li> * <li>{@link #projects}</li> * <li>{@link #errorMsg} if an error occurs</li> * @param projects project to use query. If empty, a none-project opengrok * setup is assumed (i.e. DATA_ROOT/index will be used instead of possible // the Query created by the QueryBuilder // just 1 project selected //TODO might need to rewrite to Project instead of // String , need changes in projects.jspf too // TODO check if below is somehow reusing sessions so we don't // requery again and again, I guess 2min timeout sessions could be // usefull, since you click on the next page within 2mins, if not, // errorMsg = "Index database(s) not found: " + e.getMessage(); errorMsg =
"Index database(s) not found.";
* Start the search prepared by {@link #prepareExec(SortedSet)}. * It does nothing if {@link #redirect} or {@link #errorMsg} have a * none-{@code null} value. * <li>all fields required for and populated by {@link #prepareExec(SortedSet)})</li> * <li>{@link #start} (default: 0)</li> * <li>{@link #maxItems} (default: 0)</li> * <li>{@link #isCrossRefSearch} (default: false)</li> * <li>{@link #hits} (see {@link TopFieldDocs#scoreDocs})</li> * <li>{@link #totalHits} (see {@link TopFieldDocs#totalHits})</li> * <li>{@link #contextPath}</li> * <li>{@link #errorMsg} if an error occurs</li> * <li>{@link #redirect} if certain conditions are met</li> // Bug #3900: Check if this is a search for a single term, and that // term is a definition. If that's the case, and we only have one match, // we'll generate a direct link instead of a listing. // Attempt to create a direct link to the definition if we search for // one single definition term AND we have exactly one match AND there // is only one definition of that symbol in the document that matches. // @TODO fix me. I should try to figure out where the exact hit is // instead of returning a page with just _one_ entry in.... errorMsg =
"Too many results for wildcard!";
* If a search did not return a hit, one may use this method to obtain * suggestions for a new search. * <li>{@link #projects}</li> * <li>{@link #dataRoot}</li> * <li>{@link #builder}</li> * @return a possible empty list of sugeestions. // TODO it seems the only true spellchecker is for // below field, see IndexDatabase // createspellingsuggestions ... * Prepare the fields to support printing a fullblown summary. Does nothing * if {@link #redirect} or {@link #errorMsg} have a none-{@code null} value. * <li>{@link #query}</li> * <li>{@link #builder}</li> * Otherwise the following fields are set (includes {@code null}): * <li>{@link #sourceContext}</li> * <li>{@link #summerizer}</li> * <li>{@link #historyContext}</li> * Free any resources associated with this helper (that includes closing * the used {@link #searcher}).