SearchEngine.java revision 985
0N/A * The contents of this file are subject to the terms of the 0N/A * Common Development and Distribution License (the "License"). 0N/A * You may not use this file except in compliance with the License. 0N/A * language governing permissions and limitations under the License. 0N/A * When distributing Covered Code, include this CDDL HEADER in each 0N/A * If applicable, add the following below this CDDL HEADER, with the 405N/A * fields enclosed by brackets "[]" replaced with your own identifying 0N/A * information: Portions Copyright [yyyy] [name of copyright owner] 928N/A * Copyright 2010 Sun Micosystems. All rights reserved. 0N/A * Use is subject to license terms. 0N/A * This is an encapsulation of the details on how to seach in the index 816N/A * @author Trond Norbye 2005 928N/A * @author Lubos Kosco 2010 - upgrade to lucene 3.0.0 615N/A /** Message text used when logging exceptions thrown when searching. */ 947N/A //NOTE below will need to be changed after new lucene upgrade, if they 947N/A //increase the version - every change of below makes us incompatible with the 947N/A //old index and we need to ask for reindex 947N/A /** version of lucene index common for whole app*/ 0N/A * Holds value of property definition. 0N/A * Holds value of property file. 0N/A * Holds value of property freetext. 0N/A * Holds value of property history. 0N/A * Holds value of property symbol. 0N/A * Holds value of property indexDatabase. 816N/A // internal structure to hold the results from lucene 0N/A * Creates a new instance of SearchEngine 985N/A * Create a query parser customized for OpenGrok. 985N/A * @return a query parser 816N/A * @param paging whether to use paging (if yes, first X pages will load faster) 816N/A * @param root which db to search 816N/A * @param paging whether to use paging (if yes, first X pages will load faster) 816N/A * @param root list of projects to search 0N/A * Execute a search. Before calling this function, you must set the 0N/A * appropriate seach critera with the set-functions. 816N/A * Note that this search will return the first cachePages of hitsPerPage, for more you need to call more 830N/A * @return The number of hits 830N/A //TODO optimize if only one project by falling back to SingleDatabase ? 234N/A // search the index database 816N/A * get results , if no search was started before, no results are returned 816N/A * this method will requery if end end is more than first query from search, 816N/A * hence performance hit applies, if you want results in later pages than number of cachePages 816N/A * also end has to be bigger than start ! 816N/A * @param start start of the hit list 816N/A * @param end end of the hit list 816N/A * @param ret list of results from start to end or null/empty if no search was started 816N/A //return if no start search() was done 816N/A //TODO check if below fits for if end=old hits.length, or it should include it 816N/A //do the requery, we want more than 5 pages 816N/A }
catch (
Exception e) {
// this exception should never be hit, since search() will hit this before 816N/A //TODO generation of ret(results) could be cashed and consumers of engine would just print them in whatever form they need, this way we could get rid of docs 816N/A // the only problem is that count of docs is usually smaller than number of results 816N/A //TODO FIX below fragmenter according to either summarizer or context (to get line numbers, might be hard, since xref writers will need to be fixed too, they generate just one line of html code now :( ) 0N/A * Getter for property definition. 0N/A * @return Value of property definition. 0N/A * Setter for property definition. 0N/A * @param definition New value of property definition. 0N/A * Getter for property file. 0N/A * @return Value of property file. 0N/A * Setter for property file. 0N/A * @param file New value of property file. 0N/A * Getter for property freetext. 0N/A * @return Value of property freetext. 0N/A * Setter for property freetext. 0N/A * @param freetext New value of property freetext. 0N/A * Getter for property history. 0N/A * @return Value of property history. 0N/A * Setter for property history. 0N/A * @param history New value of property history. 0N/A * Getter for property symbol. 0N/A * @return Value of property symbol. 0N/A * Setter for property symbol. 0N/A * @param symbol New value of property symbol.