/*
* 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
* @author Lubos Kosco 2012 - upgrade to lucene 4.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()
}
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
*/
}
}
}
/**
*
* @param paging whether to use paging (if yes, first X pages will load
* faster)
* @param root list of projects to search
* @throws IOException
*/
int ii = 0;
}
int noThreads = 2 + (2 * Runtime.getRuntime().availableProcessors()); //TODO there might be a better way for counting this - or we should honor the command line option here too!
} else {
}
}
}
}
}
/**
* 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 (env.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) {
}
try {
if (historyContext.isEmpty()) {
}
} catch (Exception e) {
}
}
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) { // this exception 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 {
int l = 0;
Reader r;
r = new TagFilter(new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(data + "/xref" + filename + ".gz")))));
} else {
}
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 {
OpenGrokLogger.getLogger().log(Level.WARNING, "Unknown genre: {0} for {1}", new Object[]{genre, filename});
}
} catch (FileNotFoundException exp) {
OpenGrokLogger.getLogger().log(Level.WARNING, "Couldn''t read summary from {0} ({1})", new Object[]{filename, exp.getMessage()});
}
}
if (historyContext != null) {
}
if (!hasContext) {
}
} catch (IOException e) {
} catch (ClassNotFoundException e) {
} catch (HistoryException e) {
}
}
}
/**
* Getter for property definition.
*
* @return Value of property definition.
*/
return this.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 this.file;
}
/**
* Setter for property file.
*
* @param file New value of property file.
*/
}
/**
* Getter for property freetext.
*
* @return Value of property freetext.
*/
return this.freetext;
}
/**
* Setter for property freetext.
*
* @param freetext New value of property freetext.
*/
}
/**
* Getter for property history.
*
* @return Value of property history.
*/
return this.history;
}
/**
* Setter for property history.
*
* @param history New value of property history.
*/
}
/**
* Getter for property symbol.
*
* @return Value of property symbol.
*/
return this.symbol;
}
/**
* Setter for property symbol.
*
* @param symbol New value of property symbol.
*/
}
}