search.jsp revision a66e7a81c079afbe13c5a6c0b5bd2c0a776b83f6
5887N/ASee LICENSE.txt included in this distribution for the specific
5887N/Afile and include the License file at LICENSE.txt.
5887N/A--%><%@ page import = "javax.servlet.*,
5887N/AString q = request.getParameter("q");
5887N/AString defs = request.getParameter("defs");
5887N/AString refs = request.getParameter("refs");
5887N/AString hist = request.getParameter("hist");
5887N/AString path = request.getParameter("path");
5887N/AString sort = request.getParameter("sort");
5887N/A<%@ include file="projects.jspf" %>
5887N/AString context = request.getContextPath();
5887N/Aif( defs != null && defs.equals("")) defs = null;
5887N/Aif( refs != null && refs.equals("")) refs = null;
5887N/Aif( hist != null && hist.equals("")) hist = null;
5887N/Aif( path != null && path.equals("")) path = null;
5887N/Aif( sort != null && sort.equals("")) sort = null;
5887N/Aif (project != null && project.equals("")) project = null;
5887N/A Searcher searcher = null; //the searcher used to open/search the index
5887N/A IndexReader ireader = null; //the reader used to open/search the index
5887N/A String DATA_ROOT = env.getDataRootPath();
5887N/A if(DATA_ROOT.equals("")) {
5887N/A if(!data_root.isDirectory()) {
5887N/A throw new Exception("DATA_ROOT parameter in web.xml does not exist or is not a directory!");
5887N/A ireader = IndexReader.open(DATA_ROOT + "/index");
5887N/A //String date = request.getParameter("date");
5887N/A for (String s : project.split(" ")) {
5887N/A qstr = sb.toString();
5887N/A query = qparser.parse(qstr); //parse the
5887N/A if (sort == null || sort.equals("relevancy")) {
5887N/A hits = searcher.search(query);
5887N/A else if (sort.equals("lastmodtime")) {
5887N/A hits = searcher.search(query, new Sort("date", true));
5887N/A hits = searcher.search(query);
5887N/A } catch (BooleanQuery.TooManyClauses e) {
5887N/A errorMsg = "<b>Error:</b><br/>" + Util.Htmlize(qstr) + "<br/>" + Util.Htmlize(e.getMessage());
5887N/A<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5887N/A<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
5887N/A <link rel="alternate stylesheet" type="text/css" media="all" title="Paper White" href="print.css"/>
<tr><td align="right"> Full Search </td><td><input class="q" name="q" size="45" style="width: 300px" value="<%=Util.formQuoteEscape(q)%>"/></td></tr>
<tr><td align="right"> Definition </td><td><input class="q" name="defs" size="25" style="width: 300px" value="<%=Util.formQuoteEscape(defs)%>"/></td></tr>
<tr><td align="right"> Symbol </td><td><input class="q" name="refs" size="25" style="width: 300px" value="<%=Util.formQuoteEscape(refs)%>"/></td></tr>
<tr><td align="right"> File Path </td><td><input class="q" name="path" size="25" style="width: 300px" value="<%=Util.formQuoteEscape(path)%>"/></td></tr>
<tr><td align="right"> History </td><td><input class="q" name="hist" size="25" style="width: 300px" value="<%=Util.formQuoteEscape(hist)%>"/></td></tr>
<% if (sort == null || sort.equals("relevancy")) { %>
<tr><td align="right"> sort by </td><td><select class="q" name="sort"><option value="relevancy" selected>relevancy</option><option value="lastmodtime">last modified time</option></select></td></tr>
else if (sort.equals("lastmodtime")) { %>
<tr><td align="right"> sort by </td><td><select class="q" name="sort"><option value="relevancy">relevancy</option><option value="lastmodtime" selected>last modified time</option></select></td></tr>
<tr><td align="right"> sort by </td><td><select class="q" name="sort"><option value="relevancy" selected>relevancy</option><option value="lastmodtime">last modified time</option></select></td></tr>
<% for (Project p : env.getProjects()) {
%><option value="<%=Util.formQuoteEscape(p.getPath())%>"<%=p.getPath().equals(project) ? " selected" : ""%>><%=Util.formQuoteEscape(p.getDescription())%></option><%
<tr><td></td><td> <input class="submit" type="submit" value="Search"/> | <input class="submit"
onClick="document.sbox.q.value='';document.sbox.defs.value='';document.sbox.refs.value='';document.sbox.path.value='';document.sbox.hist.value='';" type="button" value=" Clear "
/> | <a href="help.html">Help</a></td></tr>
} else if (hits.length() == 0) {
String ngramIndex = env.getDataRootPath() + "/spellIndex";
IndexReader spellReader = IndexReader.open(ngramIndex);
toks = q.split("[\t ]+");
for(int j=0; j<toks.length; j++) {
String[] ret = NGramSpeller.suggestUsingNGrams(spellSearcher,toks[j].toLowerCase(), 3, 4, 3, 5, 3, 2, 0, null, false);
for(int i = 0;i < ret.length; i++) {
toks = refs.split("[\t ]+");
for(int j=0; j<toks.length; j++) {
String[] ret = NGramSpeller.suggestUsingNGrams(spellSearcher,toks[j].toLowerCase(),3, 4, 3, 5, 3, 2, 0, null, false);
for(int i = 0;i < ret.length; i++) {
toks = defs.split("[\t ]+");
for(int j=0; j<toks.length; j++) {
String[] ret = NGramSpeller.suggestUsingNGrams(spellSearcher,toks[j].toLowerCase(),3, 4, 3, 5, 3, 2, 0, null, false);
for(int i = 0;i < ret.length; i++) {
%><p> Your search <b><%=query.toString()%></b> did not match any files.
if ( max < hits.length()) {
if((start + max) < hits.length()) {
thispage = hits.length() - start;
String url = (q == null ? "" : "&q=" + Util.URIEncode(q) ) +
(defs == null ? "" : "&defs=" + Util.URIEncode(defs)) +
(refs == null ? "" : "&refs=" + Util.URIEncode(refs)) +
(path == null ? "" : "&path=" + Util.URIEncode(path)) +
(hist == null ? "" : "&hist=" + Util.URIEncode(hist)) +
(sort == null ? "" : "&sort=" + Util.URIEncode(sort));
labelStart = sstart/max + 1;
for(int i=sstart; i<hits.length() && label <= labelEnd; i+= max) {
slider.append("<span class=\"sel\">" + label + "</span>");
} else if(label == labelEnd && i < hits.length()) {
arr = label < 10 ? " " + label : String.valueOf(label);
slider.append("<a class=\"more\" href=\"search?n=" + max + "&start=" + i + url + "\">"+
thispage = hits.length() - start; // set the max index to max or last
%> Searched <b><%=query.toString()%></b> (Results <b><%=start+1%> -
<%=thispage+start%></b> of <b><%=hits.length()%></b>) sorted by <%=sort%> <p><%=slider != null ?
slider.toString(): ""%></p>
Results.prettyPrintHTML(hits, start, start+thispage,
ef.close();
<b> Completed in <%=(new Date()).getTime() - starttime.getTime()%> milliseconds </b> <br/>
%><br/></div><%@include file="foot.jspf"%><%