SearchEngine.java revision 1419
824N/A * The contents of this file are subject to the terms of the 824N/A * Common Development and Distribution License (the "License"). 824N/A * You may not use this file except in compliance with the License. 824N/A * language governing permissions and limitations under the License. 824N/A * When distributing Covered Code, include this CDDL HEADER in each 824N/A * If applicable, add the following below this CDDL HEADER, with the 824N/A * fields enclosed by brackets "[]" replaced with your own identifying 824N/A * information: Portions Copyright [yyyy] [name of copyright owner] 824N/A * Copyright 2010 Sun Micosystems. All rights reserved. 824N/A * Use is subject to license terms. 824N/A * This is an encapsulation of the details on how to seach in the index 824N/A * @author Trond Norbye 2005 824N/A * @author Lubos Kosco 2010 - upgrade to lucene 3.0.0 824N/A * @author Lubos Kosco 2011 - upgrade to lucene 3.5.0 824N/A /** Message text used when logging exceptions thrown when searching. */ 824N/A //NOTE below will need to be changed after new lucene upgrade, if they 824N/A //increase the version - every change of below makes us incompatible with the 824N/A //old index and we need to ask for reindex 824N/A /** version of lucene index common for whole app*/ 824N/A * Holds value of property definition. 824N/A * Holds value of property file. 824N/A * Holds value of property freetext. 824N/A * Holds value of property history. 824N/A * Holds value of property symbol. 824N/A * Holds value of property indexDatabase. 824N/A // internal structure to hold the results from lucene 824N/A * Creates a new instance of SearchEngine 824N/A * Create a QueryBuilder using the fields that have been set on this 824N/A * @return a query builder 824N/A * @param paging whether to use paging (if yes, first X pages will load faster) 824N/A * @param root which db to search 824N/A * @param paging whether to use paging (if yes, first X pages will load faster) 824N/A * @param root list of projects to search 824N/A * Execute a search. Before calling this function, you must set the 824N/A * appropriate seach critera with the set-functions. 824N/A * Note that this search will return the first cachePages of hitsPerPage, for more you need to call more 824N/A * @return The number of hits 824N/A //TODO optimize if only one project by falling back to SingleDatabase ? 824N/A // search the index database 824N/A * get results , if no search was started before, no results are returned 824N/A * this method will requery if end end is more than first query from search, 824N/A * hence performance hit applies, if you want results in later pages than number of cachePages 824N/A * also end has to be bigger than start ! 824N/A * @param start start of the hit list 824N/A * @param end end of the hit list 824N/A * @param ret list of results from start to end or null/empty if no search was started 824N/A //return if no start search() was done 824N/A //TODO check if below fits for if end=old hits.length, or it should include it 824N/A //do the requery, we want more than 5 pages }
catch (
Exception e) {
// this exception should never be hit, since search() will hit this before //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 // the only problem is that count of docs is usually smaller than number of results boolean alt = (
ii %
2 ==
0);
//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 :( ) * Getter for property definition. * @return Value of property definition. * 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.