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