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