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