/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/**
* This is an encapsulation of the details on how to seach in the index
* database.
*
* @author Trond Norbye 2005
* @author Lubos Kosco 2010 - upgrade to lucene 3.0.0
* @author Lubos Kosco 2011 - upgrade to lucene 3.5.0
* @author Lubos Kosco 2012 - upgrade to lucene 3.6.0
*/
public class SearchEngine {
/** Message text used when logging exceptions thrown when searching. */
//NOTE below will need to be changed after new lucene upgrade, if they
//increase the version - every change of below makes us incompatible with the
//old index and we need to ask for reindex
/** version of lucene index common for whole app*/
/**
* Holds value of property definition.
*/
/**
* Holds value of property file.
*/
/**
* Holds value of property freetext.
*/
/**
* Holds value of property history.
*/
/**
* Holds value of property symbol.
*/
/**
* Holds value of property indexDatabase.
*/
// internal structure to hold the results from lucene
private static final boolean docsScoredInOrder = false;
boolean allCollected;
/**
* Creates a new instance of SearchEngine
*/
public SearchEngine() {
}
/**
* Create a QueryBuilder using the fields that have been set on this
* SearchEngine.
*
* @return a query builder
*/
return new QueryBuilder()
}
/**
* Check, whether a query can be build with current information available.
* @return {@code true} if a query could be build.
*/
public boolean isValidQuery() {
boolean ret;
try {
} catch (Exception e) {
ret = false;
}
return ret;
}
/**
*
* @param paging whether to use paging (if yes, first X pages will load faster)
* @param root which db to search
* @throws IOException
*/
@SuppressWarnings("resource")
}
}
}
/**
*
* @param paging whether to use paging (if yes, first X pages will load faster)
* @param root list of projects to search
* @throws IOException
*/
throws IOException
{
int ii = 0;
}
// TODO there might be a better way for counting this - or we should
// honor the command line option here too!
} else {
}
}
}
}
/**
* Get the current query used by this instance. Use {@link #isValidQuery()}
* to build one.
* @return current query as string
*/
}
/**
* Execute a search. Before calling this function, you must set the
* appropriate seach critera with the set-functions.
* Note that this search will return the first cachePages of hitsPerPage, for more you need to call more
*
* @return The number of hits
*/
public int search() {
try {
if (cfg.hasProjects()) {
// search all projects
// TODO support paging per project (in search.java)
// TODO optimize if only one project by falling back to
// SingleDatabase ?
} else {
// search the index database
searchSingleDatabase(root, true);
}
}
} catch (Exception e) {
}
summarizer = null;
try {
if (sourceContext.isEmpty()) {
}
} catch (Exception e) {
+ e.getMessage());
}
try {
if (historyContext.isEmpty()) {
}
} catch (Exception e) {
+ e.getMessage());
}
}
return count;
}
/**
* Get results , if no search was started before, no results are returned
* this method will requery if end end is more than first query from search,
* hence performance hit applies, if you want results in later pages than
* number of cachePages
* also end has to be bigger than start !
* @param start start of the hit list
* @param end end of the hit list
* was started
*/
// return if no start search() was done
return;
}
// TODO check if below fits for if end=old hits.length, or it should
// include it
// do the requery, we want more than 5 pages
try {
} catch (Exception e) {
// should never be hit, since search() will hit this before
}
try {
} catch (Exception e) {
}
}
allCollected=true;
}
// 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 hasContext = false;
try {
}
if (sourceContext != null) {
try {
&& summarizer != null)
{
int l = 0;
@SuppressWarnings("resource")
try {
} finally {
}
// 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 :( )
}
hasContext = true;
}
}
} else {
+ filename + "'");
}
} catch (FileNotFoundException exp) {
}
}
if (historyContext != null) {
}
if (!hasContext) {
}
} catch (IOException e) {
} catch (ClassNotFoundException e) {
} catch (HistoryException e) {
}
}
}
/**
* Getter for property definition.
*
* @return Value of property definition.
*/
return definition;
}
/**
* Setter for property definition.
*
* @param definition New value of property definition.
*/
this.definition = definition;
}
/**
* Getter for property file.
*
* @return Value of property file.
*/
return file;
}
/**
* Setter for property file.
*
* @param file New value of property file.
*/
}
/**
* Getter for property freetext.
*
* @return Value of property freetext.
*/
return freetext;
}
/**
* Setter for property freetext.
*
* @param freetext New value of property freetext.
*/
}
/**
* Getter for property history.
*
* @return Value of property history.
*/
return history;
}
/**
* Setter for property history.
*
* @param history New value of property history.
*/
}
/**
* Getter for property symbol.
*
* @return Value of property symbol.
*/
return symbol;
}
/**
* Setter for property symbol.
*
* @param symbol New value of property symbol.
*/
}
}