search.jsp revision 43
0N/ASee LICENSE.txt included in this distribution for the specific
0N/Afile and include the License file at LICENSE.txt.
0N/A--%><%@ page import = "javax.servlet.*,
0N/AString q = request.getParameter("q");
0N/AString defs = request.getParameter("defs");
0N/AString refs = request.getParameter("refs");
0N/AString hist = request.getParameter("hist");
0N/AString path = request.getParameter("path");
0N/AString context = request.getContextPath();
0N/Aif( defs != null && defs.equals("")) defs = null;
0N/Aif( refs != null && refs.equals("")) refs = null;
0N/Aif( hist != null && hist.equals("")) hist = null;
0N/Aif( path != null && path.equals("")) path = null;
0N/A Searcher searcher = null; //the searcher used to open/search the index
0N/A IndexReader ireader = null; //the reader used to open/search the index
0N/A if(DATA_ROOT.equals("")) {
0N/A if(!data_root.isDirectory()) {
0N/A ireader = IndexReader.open(DATA_ROOT + "/index");
0N/A //String date = request.getParameter("date");
0N/A query = qparser.parse(qstr); //parse the
0N/A hits = searcher.search(query);
0N/A } catch (BooleanQuery.TooManyClauses e) {
0N/A<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
0N/A<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
0N/A <link rel="alternate stylesheet" type="text/css" media="all" title="Paper White" href="print.css"/>
0N/A <tr><td align="right"> Full Search </td><td><input class="q" name="q" size="45" value="<%= (q == null ? "" : Util.formQuoteEscape(q))%>"/></td></tr>
0N/A <tr><td align="right"> Definition </td><td><input class="q" name="defs" size="25" value="<%= (defs == null ? "" : Util.formQuoteEscape(defs))%>"/></td></tr>
0N/A <tr><td align="right"> Symbol </td><td><input class="q" name="refs" size="25" value="<%=(refs == null ? "" : Util.formQuoteEscape(refs))%>"/></td></tr>
0N/A <tr><td align="right"> File Path </td><td><input class="q" name="path" size="25" value="<%=(path == null ? "" : Util.formQuoteEscape(path))%>"/></td></tr>
0N/A <tr><td align="right"> History </td><td><input class="q" name="hist" size="25" value="<%=(hist == null ? "" : Util.formQuoteEscape(hist))%>"/></td></tr>
0N/A <tr><td></td><td> <input class="submit" type="submit" value="Search"/> | <input class="submit"
0N/A 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 "
0N/A } else if (hits.length() == 0) {
0N/A IndexReader spellReader = IndexReader.open(ngramIndex);
0N/A for(int j=0; j<toks.length; j++) {
0N/A String[] ret = NGramSpeller.suggestUsingNGrams(spellSearcher,toks[j].toLowerCase(), 3, 4, 3, 5, 3, 2, 0, null, false);
0N/A for(int i = 0;i < ret.length; i++) {
0N/A toks = refs.split("[\t ]+");
0N/A for(int j=0; j<toks.length; j++) {
0N/A String[] ret = NGramSpeller.suggestUsingNGrams(spellSearcher,toks[j].toLowerCase(),3, 4, 3, 5, 3, 2, 0, null, false);
0N/A for(int i = 0;i < ret.length; i++) {
0N/A toks = defs.split("[\t ]+");
0N/A for(int j=0; j<toks.length; j++) {
0N/A String[] ret = NGramSpeller.suggestUsingNGrams(spellSearcher,toks[j].toLowerCase(),3, 4, 3, 5, 3, 2, 0, null, false);
0N/A for(int i = 0;i < ret.length; i++) {
0N/A %><p> Your search <b><%=query.toString()%></b> did not match any files.
0N/A if ( max < hits.length()) {
0N/A if((start + max) < hits.length()) {
0N/A thispage = hits.length() - start;
0N/A String url = (q == null ? "" : "&q=" + Util.URIEncode(q) ) +
0N/A (defs == null ? "" : "&defs=" + Util.URIEncode(defs)) +
0N/A (refs == null ? "" : "&refs=" + Util.URIEncode(refs)) +
0N/A (path == null ? "" : "&path=" + Util.URIEncode(path)) +
0N/A (hist == null ? "" : "&hist=" + Util.URIEncode(hist));
0N/A labelStart = sstart/max + 1;
0N/A for(int i=sstart; i<hits.length() && label <= labelEnd; i+= max) {
0N/A slider.append("<span class=\"sel\">" + label + "</span>");
0N/A } else if(label == labelEnd && i < hits.length()) {
0N/A arr = label < 10 ? " " + label : String.valueOf(label);
0N/A slider.append("<a class=\"more\" href=\"search?n=" + max + "&start=" + i + url + "\">"+
0N/A thispage = hits.length() - start; // set the max index to max or last
0N/A %> Searched <b><%=query.toString()%></b> (Results <b><%=start+1%> -
0N/A <%=thispage+start%></b> of <b><%=hits.length()%></b>) <p><%=slider != null ?
0N/A slider.toString(): ""%></p>
0N/A ef = new EftarFileReader(getServletContext().getInitParameter("DATA_ROOT") + "/index/dtags.eftar");
0N/A Results.prettyPrintHTML(hits, start, start+thispage,
0N/A <b> Completed in <%=(new Date()).getTime() - starttime.getTime()%> milliseconds </b> <br/>