Apache Lucene open-source search software
new stuff from Bryan
Erik Hatcherf1ff538655fd
diff --git a/sandbox/contributions/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballFilter.java b/sandbox/contributions/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballFilter.javaindex 26af399d7e6..b1164881e60 100644--- a/sandbox/contributions/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballFilter.java+++ b/sandbox/contributions/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballFilter.java@@ -91,7 +91,7 @@ public class SnowballFilter extends TokenFilter {stemmer = (SnowballProgram) stemClass.newInstance();stemMethod = stemClass.getMethod("stem", new Class[0]);} catch (Exception e) {- throw new RuntimeException(e);+ throw new RuntimeException();}}@@ -104,7 +104,7 @@ public class SnowballFilter extends TokenFilter {try {stemMethod.invoke(stemmer, EMPTY_ARGS);} catch (Exception e) {- throw new RuntimeException(e);+ throw new RuntimeException();}return new Token(stemmer.getCurrent(),token.startOffset(), token.endOffset(), token.type());diff --git a/sandbox/contributions/taglib/WEB-INF/classes/com/netwebapps/taglib/search/SearchTag.java b/sandbox/contributions/taglib/WEB-INF/classes/com/netwebapps/taglib/search/SearchTag.javaindex 8defe139312..9da91f32488 100755--- a/sandbox/contributions/taglib/WEB-INF/classes/com/netwebapps/taglib/search/SearchTag.java+++ b/sandbox/contributions/taglib/WEB-INF/classes/com/netwebapps/taglib/search/SearchTag.java@@ -1,21 +1,37 @@package com.netwebapps.taglib.search;+import java.io.File;+import java.io.IOException;import java.util.*;-import javax.servlet.jsp.*;-import javax.servlet.jsp.tagext.*;-import javax.servlet.http.*;-import java.io.*;-import org.apache.lucene.analysis.*;-import org.apache.lucene.document.*;-import org.apache.lucene.index.*;-import org.apache.lucene.search.*;-import org.apache.lucene.queryParser.*;+import javax.servlet.http.HttpServletRequest;+import javax.servlet.jsp.JspException;+import javax.servlet.jsp.PageContext;+import javax.servlet.jsp.tagext.BodyTagSupport;++import org.apache.lucene.analysis.Analyzer;+import org.apache.lucene.analysis.SimpleAnalyzer;+import org.apache.lucene.analysis.StopAnalyzer;+import org.apache.lucene.analysis.WhitespaceAnalyzer;+import org.apache.lucene.analysis.de.GermanAnalyzer;+import org.apache.lucene.analysis.de.WordlistLoader;+import org.apache.lucene.analysis.standard.StandardAnalyzer;+import org.apache.lucene.document.Document;+import org.apache.lucene.document.Field;+import org.apache.lucene.index.IndexReader;+import org.apache.lucene.queryParser.ParseException;+import org.apache.lucene.queryParser.QueryParser;+import org.apache.lucene.queryParser.MultiFieldQueryParser;+import org.apache.lucene.search.Hits;+import org.apache.lucene.search.IndexSearcher;+import org.apache.lucene.search.MultiSearcher;+import org.apache.lucene.search.Query;/**- * @author Bryan LaPlante- * @param+ * @company Network Web Application+ * @url http://www.netwebapps.com+ * @author Bryan LaPlante**/public class SearchTag extends BodyTagSupport{@@ -32,49 +48,52 @@ public class SearchTag extends BodyTagSupport{private Enumeration fields = null;private HashMap aField = new HashMap();private int ROWCOUNT = 0;- private int PAGECOUNT = 1;+ private int PAGECOUNT = 0;private int HITCOUNT = 0;private boolean abort = false;private Analyzer analyzer = null;+ private Document doc = null;+ private ArrayList idxArray = new ArrayList();+ private MultiSearcher msearcher = null;+ private final int GERMANAN_ALYZER = 0;+ private final int SIMPLE_ANALYZER = 1;+ private final int STANDARD_ANALYZER = 2;+ private final int STOP_ANALYZER = 3;+ private final int WHITESPACE_ANALYZER = 4;public int startRow = 0;public int maxRows = 50;- public String rowCount = "0";- public String pageCount = "1";- public String hitCount = "0";+ public int rowCount = 0;+ public int pageCount = 1;+ public int hitCount = 0;+ public int loopCount = 0;public String firstPage = "";public String nextPage = "";public String previousPage = "";public String lastPage = "";public LinkedList pageList = new LinkedList();public boolean throwOnException = false;+ public String[] stopWords = new String[0];+ public String[] fieldList = new String[0];+ public int[] flagList = new int[0];+ public String search = "contents";+ public int analyzerType = STANDARD_ANALYZER;public int doStartTag() throws JspException{-- doSearch();- if(abort){- rowCount = new Integer(startRow + ROWCOUNT).toString();- pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);- return SKIP_BODY;- }- searchItr = hitArray.iterator();- if(searchItr.hasNext()){- aField = (HashMap) searchItr.next();- rowCount = new Integer(startRow + ROWCOUNT++).toString();- pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);- return EVAL_BODY_AGAIN;- }- return SKIP_BODY;+ rowCount = startRow + ROWCOUNT++;+ loopCount++;+ pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);+ return EVAL_BODY_AGAIN;}public void doInitBody() throws JspException{+ doSearch();if(!abort){- doSearch();searchItr = hitArray.iterator();if(searchItr.hasNext()){aField = (HashMap) searchItr.next();- rowCount = new Integer(startRow + ROWCOUNT).toString();+ rowCount = startRow + ROWCOUNT++;pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);}}@@ -83,7 +102,9 @@ public class SearchTag extends BodyTagSupport{public int doAfterBody() throws JspException{if(abort){- rowCount = new Integer(startRow + ROWCOUNT).toString();+ hitCount = 0;+ loopCount = 0;+ rowCount = startRow + ROWCOUNT;pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);return SKIP_BODY;}@@ -98,7 +119,8 @@ public class SearchTag extends BodyTagSupport{if(searchItr.hasNext()){aField = (HashMap) searchItr.next();- rowCount = new Integer(startRow + ROWCOUNT++).toString();+ rowCount = startRow + ROWCOUNT++;+ loopCount++;pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);return EVAL_BODY_AGAIN;}@@ -108,6 +130,8 @@ public class SearchTag extends BodyTagSupport{public int doEndTag() throws JspException{if(abort){+ hitCount = 0;+ pageContext.setAttribute(getId(),this,PageContext.PAGE_SCOPE);return EVAL_PAGE;}@@ -135,6 +159,25 @@ public class SearchTag extends BodyTagSupport{}public void release(){+ hitMap = null;+ hitArray = null;+ collection = "";+ searcher = null;+ query = null;+ hits = null;+ thispage = 0;+ criteria = "";+ searchItr = null;+ fields = null;+ aField = new HashMap();+ ROWCOUNT = 0;+ PAGECOUNT = 1;+ HITCOUNT = 0;+ abort = false;+ analyzer = null;+ doc = null;+ idxArray = null;+ msearcher = null;}public String getField(String name){@@ -150,10 +193,32 @@ public class SearchTag extends BodyTagSupport{return aField.keySet();}++ public void addCollection(String name) throws JspException{+ try {+ searcher = new IndexSearcher(IndexReader.open(name));+ idxArray.add(searcher);+ } catch (IOException e) {+ if(throwOnException){+ throw new JspException("Error occured while opening " + name + " ]: " + e);+ }+ }+ }+public void doSearch() throws JspException{try {- searcher = new IndexSearcher(IndexReader.open(collection));+ if(idxArray.size() > 0){+ IndexSearcher[] idxToArray = new IndexSearcher[idxArray.size()];+ Iterator idxIter = idxArray.iterator();+ int arrayCount = 0;+ while(idxIter.hasNext()){+ idxToArray[arrayCount++] = (IndexSearcher) idxIter.next();+ }+ msearcher = new MultiSearcher(idxToArray);+ }else{+ throw new JspException("No collection has been specified");+ }} catch (IOException e) {if(throwOnException){throw new JspException("IndexSearcher(IndexReader.open(collection)): " + e);@@ -161,31 +226,80 @@ public class SearchTag extends BodyTagSupport{abort = true;}if(!abort){- analyzer = new StopAnalyzer();+ // choosing the type of analyzer to use in this search+ switch (analyzerType) {+ case GERMANAN_ALYZER:+ if(stopWords.length > 0){+ analyzer = new GermanAnalyzer(stopWords);+ }else{+ if(throwOnException){+ throw new JspException("In order to use a GermanAnalyzer you must provide a list of stop words");+ }+ abort = true;+ }+ break;+ case SIMPLE_ANALYZER:+ analyzer = new SimpleAnalyzer();+ break;+ case STANDARD_ANALYZER:+ if(stopWords.length > 0){+ analyzer = new StandardAnalyzer(stopWords);+ }else{+ analyzer = new StandardAnalyzer();+ }+ break;+ case STOP_ANALYZER:+ if(stopWords.length > 0){+ analyzer = new StopAnalyzer(stopWords);+ }else{+ analyzer = new StopAnalyzer();+ }+ break;+ case WHITESPACE_ANALYZER:+ analyzer = new WhitespaceAnalyzer();+ break;++ default :+ if(stopWords.length > 0){+ analyzer = new StandardAnalyzer(stopWords);+ }else{+ analyzer = new StandardAnalyzer();+ }+ break;+ }try {- query = QueryParser.parse(criteria, "contents", analyzer);+ // choose a query parser+ if(fieldList.length > 0){+ if(flagList.length > 0){+ query = MultiFieldQueryParser.parse(criteria,fieldList,flagList,analyzer);+ }else{+ query = MultiFieldQueryParser.parse(criteria,fieldList,analyzer);+ }+ }else{+ query = QueryParser.parse(criteria, search, analyzer);+ }} catch (ParseException e) {if(throwOnException){- throw new JspException("QueryParser.parse(criteria,contents,analyzer): " + e);+ throw new JspException("If using fieldList and or flagList check to see you have the same number of items in each: " + e);}abort = true;}if(!abort){try {- hits = searcher.search(query);+ hits = msearcher.search(query);} catch (IOException e) {if(throwOnException){- throw new JspException("searcher.search(query): " + e);+ throw new JspException("msearcher.search(query): " + e);}abort = true;}if(!abort){- hitCount = new Integer(hits.length()).toString();+ hitCount = hits.length();HITCOUNT = hits.length();- PAGECOUNT = PAGECOUNT = (int) (( (double) startRow) / maxRows );- pageCount = new Integer(PAGECOUNT).toString();+ PAGECOUNT = (int) (( (double) startRow) / maxRows );+ pageCount = PAGECOUNT;thispage = maxRows;if ((startRow + maxRows) > hits.length()) {thispage = hits.length() - startRow;@@ -193,7 +307,6 @@ public class SearchTag extends BodyTagSupport{hitArray = new ArrayList();for (int i = startRow; i < (thispage + startRow); i++) {hitMap = new HashMap();- Document doc = null;try {doc = hits.doc(i);} catch (IOException e) {@@ -225,11 +338,16 @@ public class SearchTag extends BodyTagSupport{}}}- }-- /* setters */--+ if(msearcher != null){+ try {+ msearcher.close();+ } catch (IOException e) {+ if(throwOnException){+ throw new JspException("A problem occured trying to close the searcher : " + e);+ }+ }+ }+ }public void setCriteria(String criteria){this.criteria = criteria;@@ -261,15 +379,20 @@ public class SearchTag extends BodyTagSupport{this.maxRows = maxRows;}- public void setCollection(String collection){- this.collection = collection;+ public void setCollection(String collection) throws JspException{+ idxArray = new ArrayList();+ String[] collectionArray = collection.split(",");+ for(int i=0; i<collectionArray.length; i++){+ this.addCollection(collectionArray[i]);+ }}public void setThrowOnException(String bool){this.throwOnException = new Boolean(bool).booleanValue();}-- /* getters */+ public void setThrowOnException(boolean b) {+ throwOnException = b;+ }public int getStartRow(){return startRow;@@ -278,4 +401,99 @@ public class SearchTag extends BodyTagSupport{public int getMaxRows(){return maxRows;}+ /**+ * @param string -- a comma seperated list of stop words.+ */+ public void setStopWords(String swords) throws JspException{+ Hashtable wordTable = new Hashtable();+ String[] temp = new String[wordTable.size()];+ if(swords.split(",").length > 0){+ String[] words = swords.split(",");+ for (int i = 0; i < words.length; i++) {+ if(new File(words[i]).isFile()){+ wordTable.putAll(WordlistLoader.getWordtable(words[i]));+ }else{+ wordTable.put(words[i], words[i]);+ }+ }+ temp = new String[wordTable.size()];++ int count = 0;+ if(wordTable.size() > 0){+ Iterator wtIter = wordTable.keySet().iterator();+ while (wtIter.hasNext()){+ temp[count++] = (String) wtIter.next();+ }+ }+ }+ stopWords = temp;+ }++// public void setStopWords(String[] swords) throws JspException{+// stopWords = swords;+// }++ /**+ * @param string+ */+ public void setFlagList(String fg) {+ int[] list = new int[0];+ if(fg.split(",").length > 0){+ String[] ssplit = fg.split(",");+ Integer fsplit = new Integer(fg.split(",").length);+ list = new int[fsplit.intValue()];+ for(int i=0; i < fsplit.intValue(); i++){+ if(ssplit[i].equalsIgnoreCase("NORMAL")){+ list[i] = MultiFieldQueryParser.NORMAL_FIELD;+ }else if(ssplit[i].equalsIgnoreCase("PROHIBITED")){+ list[i] = MultiFieldQueryParser.PROHIBITED_FIELD;+ }else if(ssplit[i].equalsIgnoreCase("REQUIRED")){+ list[i] = MultiFieldQueryParser.REQUIRED_FIELD;+ }+ }+ }+ flagList = list;+ }++ /**+ * @param string+ */+ public void setFieldList(String fl) {+ if(fl.split(",").length > 0){+ fieldList = fl.split(",");+ }+ }+ /**+ * @param string+ */+ public void setFieldList(String[] fl) {+ fieldList = fl;+ }++ /**+ * @param string+ */+ public void setSearch(String string) {+ search = string;+ }++ /**+ * @param string+ */+ public void setAnalyzerType(String atype) {+ if(atype.equalsIgnoreCase("GERMANAN_ALYZER")){+ analyzerType = 0;+ }else if(atype.equalsIgnoreCase("SIMPLE_ANALYZER")){+ analyzerType = 1;+ }else if(atype.equalsIgnoreCase("STANDARD_ANALYZER")){+ analyzerType = 2;+ }else if(atype.equalsIgnoreCase("STOP_ANALYZER")){+ analyzerType = 3;+ }else if(atype.equalsIgnoreCase("WHITESPACE_ANALYZER")){+ analyzerType = 4;+ }else{+ analyzerType = 2;+ }+ }+}diff --git a/sandbox/contributions/taglib/WEB-INF/classes/com/netwebapps/taglib/search/SearchTagTei.java b/sandbox/contributions/taglib/WEB-INF/classes/com/netwebapps/taglib/search/SearchTagTei.javaindex b2235ccb80e..c965d222edd 100755--- a/sandbox/contributions/taglib/WEB-INF/classes/com/netwebapps/taglib/search/SearchTagTei.java+++ b/sandbox/contributions/taglib/WEB-INF/classes/com/netwebapps/taglib/search/SearchTagTei.java@@ -1,7 +1,8 @@package com.netwebapps.taglib.search;/**- * @author Network Web Application+ * @company Network Web Application+ * @url http://www.netwebapps.com* @author Bryan LaPlante**/diff --git a/sandbox/contributions/taglib/WEB-INF/lucene-taglib.tld b/sandbox/contributions/taglib/WEB-INF/lucene-taglib.tldindex 1a28a3dec27..7bf540879a8 100755--- a/sandbox/contributions/taglib/WEB-INF/lucene-taglib.tld+++ b/sandbox/contributions/taglib/WEB-INF/lucene-taglib.tld@@ -34,7 +34,7 @@</attribute><attribute><name>collection</name>- <required>false</required>+ <required>true</required><rtexprvalue>true</rtexprvalue></attribute><attribute>@@ -47,17 +47,78 @@<required>false</required><rtexprvalue>true</rtexprvalue></attribute>+ <attribute>+ <name>analyzerType</name>+ <required>false</required>+ <rtexprvalue>true</rtexprvalue>+ </attribute>+ <attribute>+ <name>fieldList</name>+ <required>false</required>+ <rtexprvalue>true</rtexprvalue>+ </attribute>+ <attribute>+ <name>flagList</name>+ <required>false</required>+ <rtexprvalue>true</rtexprvalue>+ </attribute>+ <attribute>+ <name>search</name>+ <required>false</required>+ <rtexprvalue>true</rtexprvalue>+ </attribute>+ <attribute>+ <name>stopWords</name>+ <required>false</required>+ <rtexprvalue>true</rtexprvalue>+ </attribute></tag><tag>- <name>Collection</name>- <tagclass>com.netwebapps.taglib.search.CollectionTag</tagclass>+ <name>Column</name>+ <tagclass>com.netwebapps.taglib.search.ColumnTag</tagclass>+ <teiclass>com.netwebapps.taglib.search.ColumnTagTei</teiclass>+ <bodycontent>JSP</bodycontent><info>Adds an additional collection to the search tag.</info><attribute>- <name>directory</name>+ <name>id</name>+ <required>true</required>+ <rtexprvalue>true</rtexprvalue>+ </attribute>+ <attribute>+ <name>runOnce</name>+ <required>false</required>+ <rtexprvalue>true</rtexprvalue>+ </attribute>+ <attribute>+ <name>throwOnException</name>+ <required>false</required>+ <rtexprvalue>true</rtexprvalue>+ </attribute>+ </tag>+ <tag>+ <name>Field</name>+ <tagclass>com.netwebapps.taglib.search.FieldTag</tagclass>+ <teiclass>com.netwebapps.taglib.search.FieldTagTei</teiclass>+ <bodycontent>JSP</bodycontent>+ <info>+ Output the value for the named field in a search result, empty by default.+ </info>+ <attribute>+ <name>id</name><required>true</required><rtexprvalue>true</rtexprvalue></attribute>+ <attribute>+ <name>name</name>+ <required>true</required>+ <rtexprvalue>true</rtexprvalue>+ </attribute>+ <attribute>+ <name>throwOnException</name>+ <required>false</required>+ <rtexprvalue>true</rtexprvalue>+ </attribute></tag></taglib>diff --git a/sandbox/contributions/taglib/WEB-INF/web.xml b/sandbox/contributions/taglib/WEB-INF/web.xmlindex 461f536e20a..17301a07495 100755--- a/sandbox/contributions/taglib/WEB-INF/web.xml+++ b/sandbox/contributions/taglib/WEB-INF/web.xml@@ -7,8 +7,8 @@<session-timeout>30</session-timeout></session-config><welcome-file-list>- <welcome-file>index.jsp</welcome-file><welcome-file>index.html</welcome-file>+ <welcome-file>index.jsp</welcome-file><welcome-file>index.htm</welcome-file></welcome-file-list></web-app>diff --git a/sandbox/contributions/taglib/index.html b/sandbox/contributions/taglib/index.htmlindex 265a9d4e3b9..7dcda056d3b 100755--- a/sandbox/contributions/taglib/index.html+++ b/sandbox/contributions/taglib/index.html@@ -1,8 +1,114 @@<html>- <head>- <title>Hello World</title>- </head>- <body>- Hello World- </body>-</html>+<head>+ <title>Using Lucene Taglib</title>+ <style>+ BODY { background-color:#FFFFFF; font-size:12pt;}+ TH { color:#009696; }+ SPAN { color:color:#009696; font-size:8pt; }+ SPAN.required { color:red; font-size:12pt;}+ PRE { color:#7B007B; }+ OPTION { color:blue; font-size:10pt; font-weight:bold; }+ TD { vertical-align:top; color:blue; }+ SELECT.data { color:blue; width:175px; }+ INPUT { color:blue; width:175px; }+ SPAN.default { color:Fuchsia; }+ .default { color:Fuchsia; }+ SPAN.object { color:Purple; font-size:12pt; }+ SPAN.explained { color:black; font-size:10pt; }+ </style>+</head>+<body>++<h2 align="center">Test page for Lucene-taglib</h2>+<table border=0 width="100%">+<tr>+ <td colspan=3><b>Ledgend</b></td>+</tr>+<tr>+ <td style="width:100px;">Required field</td>+ <td style="background-color:red; width:5px;"> </td>+ <td rowspan="4" valign="top" style="padding-left:10px;" align="justify">+ <span class="explained">+ This page has been set up so that you can dynamically change the+ parameters used by the taglib to produce different results. Hopefully+ this tag library is abstract enough to address the majority of situations.++ The ledgend on the left shows which parameters are required and there+ default values. If you set throwOnException to false the errors caused by+ bad input parameter should not crash the page rather no results will be returned.+ On the other hand setting it to true will show any errors encountered by the tag.+ Some knowledge of the Lucene search engine is required to take advantage of the+ the search tags advanced features such as changing the analyzer and using+ fieldList's and flagList's. more documentation on each tag can be found in+ the docs directory in the index.html file.+ </span>+ </td>+</tr>+<tr>+ <td>Default value</td>+ <td style="background-color:Fuchsia"> </td>+</tr>+<tr>+ <td>String</td>+ <td style="background-color:blue"> </td>+</tr>+<tr>+ <td>Object</td>+ <td style="background-color:Purple;"> </td>+</tr>+</table>++<form action="result.jsp" method="get">+<input type="submit">+<table cellpadding=0 cellspacing=0 border=0>+ <tr><th><LUCENE:Search </th><td><span class="required">id="rs"</span></td><td> </td><td> </td></tr>+ <tr><td>throwOnException</td><td><select class="data" name="throwOnException"><option value="true">true</option><option class="default" value="false" SELECTED>false</option></select></td><td> </td><td> </td></tr>+ <tr><td><span class="required">collection</span></td><td><input type="text" name="collection" value="E:/search/lucene/index,E:/opt/lucene/index"></td><td colspan=2><span>"comma separated directory/path(s)"</span></td></tr>+ <tr><td><span class="required">criteria</span></td><td><input type="text" name="criteria"></td><td><span>"String"</span></td><td> </td></tr>+ <tr><td>startRow</td><td><input type="text" name="startRow" value="0"></td><td><span class="default">"0"</span></td><td> </td></tr>+ <tr><td>maxRows</td><td><input type="text" name="maxRows" value="50"></td><td><span class="default">"50"</span></td><td> </td></tr>+ <tr><td>analyzerType</td>+ <td>+ <select class="data" name="analyzerType">+ <option value="GERMANAN_ALYZER">GERMANAN_ALYZER</option>+ <option value="SIMPLE_ANALYZER">SIMPLE_ANALYZER</option>+ <option class="default" value="STANDARD_ANALYZER" selected>STANDARD_ANALYZER</option>+ <option value="STOP_ANALYZER">STOP_ANALYZER</option>+ <option value="WHITESPACE_ANALYZER">WHITESPACE_ANALYZER</option>+ </select>+ </td><td> </td><td> </td></tr>+ <tr><td>search</td><td><input type="text" name="search" value="contents"></td><td><span class="default">"contents"</span></td><td> </td></tr>+ <tr><td>stopWords</td><td><input type="text" name="stopWords"></td><td><span>"comma,separated,list"</span></td><td> </td></tr>+ <tr><td>fieldList</td><td><input type="text" name="fieldList" value="contents"></td><td><span>"comma,separated,list"</span></td><td> </td></tr>+ <tr><td>flagList</td><td><input type="text" name="flagList" value="NORMAL"></td><td><span>"NORMAL,PROHIBITED,REQUIRED"</span>></td><td> </td></tr>+ <tr><td colspan=4><%= rs.loopCount %> <br><span class="explained">int value of the current interation of the search tag</span></td></tr>+ <tr><td colspan=4><%= rs.rowCount %><br><span class="explained">int value of the current result in hitCount</span></td></tr>+ <tr><td colspan=4><%= rs.hitCount %><br><span class="explained">int value representing the total number of results</span></td></tr>+ <tr><td colspan=4><%= rs.pageCount %><br><span class="explained">int value of the offset between the maxrows and the total number of hits</span></td></tr>+ <tr><td colspan=4><%= rs.firstPage %><br><span class="explained">variable containing the query string needed by a navigation element to return you to the first page of the result</span></td></tr>+ <tr><td colspan=4><%= rs.nextPage %><br><span class="explained">variable containing the query string needed by a navigation element to move to the next page of the result</span></td></tr>+ <tr><td colspan=4><%= rs.previousPage %><br><span class="explained">variable containing the query string needed by a navigation element to return to the previous page of the result</span></td></tr>+ <tr><td colspan=4><%= rs.lastPage %><br> <span class="explained">variable containing the query string needed by a navigation element to move to the last page of the result</span></td></tr>+ <tr><td colspan=4><%= rs.score %><br> <span class="explained">returns a string representation of the float value stored in every lucene index as the value score. <br>if you want to translate it into something useful to a user you will need to create+ <br>new Float(tagid.getField("score")).floatValue() and then you can use your own conversion method <br>+ as this will return you the original float value that was stored in the index. </span></td></tr>+ <tr><td colspan=4 style="color:black"><span class="object"><%= rs.pageList %></span><br> <span style="font-size:10pt;">returns a LinkedList of query strings needed to produce links to the number of page represented <br>by the offset of the current page and the maxrows being displayed on each page. </span></td></tr>+ <tr><td colspan=4><%= rs.getField(String name) %> used by the Field tag<br> <span class="explained">used to retreive the named field from the index for that iteration of the loop. <br>If no such name exists in the index such as author the method will return an empty string.</span></td></tr>+ <tr><td colspan=4><%= rs.getFields() %> used by the Column tag<br> <span class="explained">used to retrieve a Set view of all of the fields contained in the index for each iteration of the loop, <br>most generally would be used to write your table headers when the field names are not known until runtime</span></td></tr>++ <tr><td> </td><th><LUCENE:Column </th><td><span class="required">id="col"</span></td><td> </td></tr>+ <tr><td> </td><td>runOnce</td><td><select class="data" name="runOnce"><option value="true">true</option><option class="default" value="false" SELECTED>false</option></select></td><td> </td></tr>+ <tr><td> </td><td>throwOnException</td><td><select class="data" name="columnthrowOnException"><option value="true">true</option><option class="default" value="false" SELECTED>false</option></select>></td><td> </td></tr>+ <tr><td> </td><td colspan=3><%= col.columnCount %> <span class="explained">int value of the current iteration of the column tag</span></td></tr>+ <tr><td> </td><td colspan=3><%= col.columnName %><span class="explained"> String value of the field name at columnCount</span></td></tr>+ <tr><td> </td><td> </td><th><LUCENE:Field </th><td><span class="required">id="fld"</span></td></tr>+ <tr><td> </td><td> </td><td><span class="required">name</span></td><td>"<%= col.columnName %>"</td></tr>+ <tr><td> </td><td> </td><td>throwOnException</td><td><select class="data" name="fieldthrowOnException"><option value="true">true</option><option class="default" value="false" SELECTED>false</option></select>></td></tr>+ <tr><td> </td><td> </td><td colspan=2><%= fld.value %> <span class="explained">String value of the columnName</span></td></tr>+ <tr><td> </td><td> </td><th></LUCENE:Field></th><td> </td></tr>+ <tr><td> </td><th></LUCENE:Column></th><td> </td><td> </td><tr>+ <tr><th></LUCENE:Search></th><td> </td><td> </td><td> </td></tr>+</table>+</form>+</body>+</html>\ No newline at end of filediff --git a/sandbox/contributions/taglib/readme.txt b/sandbox/contributions/taglib/readme.txtindex ef0c8806745..693ecb9b648 100755--- a/sandbox/contributions/taglib/readme.txt+++ b/sandbox/contributions/taglib/readme.txt@@ -16,18 +16,56 @@ INSTRUCTIONSDOCUMENTATION:you will find documentation and an over view of the tag library inthe docs folder of this project and the javadocs in the api folder-respectivley.+respectively.BUGS:I tried to create a .war file for this project but I am having troublegetting it to deploy properly.-PLANNED:-I am planning to document the result.jsp file line for line to explain-how to display a search result when you do not know what the names of-the search fields stored in the lucene-index. That is the way the result-page is currently written.+More like a heads up than a bug I discovered that if you have tag pooling \+turned on in Tomcat that values passed to a custom tag will not change in+the event that an exception is thrown. Catching the exception inside of+the tag or page does not help, to update the values at this point you+have to turn off tag pooling. Follow the instructions below to do this+in Tomcat.-Time permitting I want to write a couple of child tags for telling the search-tag that there are multiple index to be searched and to let it do the other-types of searches such as fuzzy and range queries.\ No newline at end of file+----------------------------------------------------------------------------++ From: Bill Barker+ Subject: Re: HELP:Tagpool sharing problems+ Date: Mon, 28 Apr 2003 22:20:20 -0700++----------------------------------------------------------------------------++In $CATALINA_HOME/conf/web.xml, locate the <servlet-name>jsp</servlet-name>+servlet, and add:+ <init-param>+ <param-name>enablePooling</param-name>+ <param-value>false</param-value>+ </init-param>++This will turn off tag-pooling. You'll also need to clear out+$CATALINA_HOME/work so that the JSP pages get re-compiled.++If you just want it turned off for one context, then you can place the+definition of the jsp servlet in your own web.xml.++If you are using:+ <servlet>+ <servlet-name>myJspPage</servlet-name>+ <jsp-page>myJspPage.jsp</jsp-page>+ </servlet>+then you also need to add the enablePooling init-param to your servlet's+definition.+++HISTORY:+1. Added more robust error handling and the ability to turn it on and+ off with a throwOnException attribute. (All tags)+2. Added a Column tag for outputting the field names found in a+ Lucene index.+3. Added a Field tag for retrieving a value for a field in a search+ result either produced by the Column tag or known in advance.+4. Added new example pages to illustrate how to use the new tags+5. The Collection tag has been deprecated, use the collection attribute+ of the Search tag instead.\ No newline at end of filediff --git a/sandbox/contributions/taglib/result.jsp b/sandbox/contributions/taglib/result.jspindex dba4e9da30a..100d8a9a7c9 100755--- a/sandbox/contributions/taglib/result.jsp+++ b/sandbox/contributions/taglib/result.jsp@@ -1,53 +1,92 @@<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">-<%@ taglib uri="/WEB-INF/lucene-taglib.tld" prefix="JSP"%>-<%@ include file="header.jsp"%>+<%@ taglib uri="/WEB-INF/lucene-taglib.tld" prefix="LUCENE"%><%@ page import="java.util.*"%>-+<html>+<head>+ <title>Using Lucene Taglib</title>+ <style>+ BODY{background-color:#F5F5F5}+ </style>+</head>+<body><%- String startRow = "0";- String maxRows = "10";- String query = request.getParameter("query");+ String startRow = "";+ String maxRows = "";+ String criteria = "";+ int colCount = 0;+ String analyzerType = "STANDARD_ANALYZER";+ String search = "contents";+ String stopWords="";+ String fieldList="";+ String flagList="";+ String collection = "E:/search/lucene/index,E:/opt/lucene/index";+ String throwOnException = "false";+ String fieldthrowOnException = "false";+ String columnthrowOnException = "false";+ String runOnce = "false";+ String query = "";+try{+ query = request.getQueryString();+ criteria = request.getParameter("criteria");startRow = request.getParameter("startRow");maxRows = request.getParameter("maxRows");+ analyzerType = request.getParameter("analyzerType");+ search = request.getParameter("search");+ stopWords = request.getParameter("stopWords");+ fieldList = request.getParameter("fieldList");+ flagList = request.getParameter("flagList");+ throwOnException = request.getParameter("throwOnException");+ fieldthrowOnException = request.getParameter("fieldthrowOnException");+ columnthrowOnException = request.getParameter("columnthrowOnException");+ runOnce = request.getParameter("runOnce");}catch(Exception e){}%>-+<h3> Search results for "<%= criteria %>"</h3><table border=3>- <JSP:Search throwOnException="false" id="rs" collection="E:/opt/lucene/index" criteria="<%= query %>" startRow="<%= startRow %>" maxRows="<%= maxRows %>">- <%-- Set allFields = rs.getFields();- int fieldSize = allFields.size();- Iterator fieldIter = allFields.iterator();-- while(fieldIter.hasNext()){- String nextField = (String) fieldIter.next();- if(!nextField.equalsIgnoreCase("summary")){- %>- <tr><td><b><%= nextField %></b></td><td><%= rs.getField(nextField) %></td></tr>- <%- }else{- %>- <tr><td colspan="2"><b><%= rs.hitCount %>|<%= nextField %></b></td></tr>- <tr><td colspan="2"><%= rs.getField(nextField) %></td></tr>- <%- }- }-- %>- </JSP:Search>+ <LUCENE:Search id="rs"+ throwOnException="<%= throwOnException %>"+ collection="<%= collection %>"+ criteria="<%= criteria %>"+ startRow="<%= startRow %>"+ maxRows="<%= maxRows %>"+ analyzerType="<%= analyzerType %>"+ search="<%= search %>"+ stopWords="<%= stopWords %>"+ fieldList="<%= fieldList %>"+ flagList="<%= flagList %>">+ <tr>+ <LUCENE:Column id="header" runOnce="true" throwOnException="false">+ <% colCount = header.columnCount; %>++ <th><b><%= header.columnName %></b></th>+ </LUCENE:Column>+ </tr>+ <LUCENE:Column id="col" throwOnException="<%= columnthrowOnException %>" runOnce="<%= runOnce %>">+ <tr>+ <td colspan="<%= col.columnCount %>"><b>[<%= rs.loopCount %>][<%= rs.rowCount %>]</b> + <LUCENE:Field id="fld" name="<%= col.columnName %>" throwOnException="<%= fieldthrowOnException %>">++ <% if(col.columnName.equalsIgnoreCase("url")){ %>+ <a href="<%= fld.value %>">+ <% } %>++ <%= fld.value %>++ <% if(col.columnName.equalsIgnoreCase("url")){ %>+ </a>+ <% } %>++ </LUCENE:Field>+ </td>+ </tr>+ </LUCENE:Column>+ </LUCENE:Search><%- int count = 0;- try{- count = new Integer(rs.hitCount).intValue();- }catch(Exception e){- out.print(e);- }- if(count <= 0){+ if(rs.hitCount <= 0){%><tr><td colspan=2>No results have been found</td>@@ -56,9 +95,45 @@}%><tr>- <td colspan=2><%= rs.hitCount %></td>+ <td><b>hitCount</b></td>+ <td colspan="<%= colCount-1 %>"><%= rs.hitCount %></td>+ </tr>+ <tr>+ <td><b>pageCount</b></td>+ <td colspan="<%= colCount-1 %>"><%= rs.pageCount %></td>+ </tr>+ <tr>+ <td><b>firstPage</b></td>+ <td colspan="<%= colCount-1 %>"><a href="<%= rs.firstPage %><%= query %>"><%= rs.firstPage %></a></td>+ </tr>+ <tr>+ <td><b>nextPage</b></td>+ <td colspan="<%= colCount-1 %>"><a href="<%= rs.nextPage %><%= query %>"><%= rs.nextPage %></a></td>+ </tr>+ <tr>+ <td><b>previousPage</b></td>+ <td colspan="<%= colCount-1 %>"><a href="<%= rs.previousPage %><%= query %>"><%= rs.previousPage %></a></td>+ </tr>+ <tr>+ <td><b>lastPage</b></td>+ <td colspan="<%= colCount-1 %>"><a href="<%= rs.lastPage %><%= query %>"><%= rs.lastPage %></a></td>+ </tr>+ <tr>+ <td colspan="<%= colCount %>">+ <select name="pagelist" onchange="location.href=this.value">+ <%+ Iterator pages = rs.pageList.iterator();+ while(pages.hasNext()){+ String listNext = (String) pages.next();+ %>+ <option value="<%= listNext %><%= query %>"><%= listNext %></option>+ <%+ }+ %>+ </select>+ </td></tr>- </table>--<%@include file="footer.jsp"%>+</table>+</body>+</html>\ No newline at end of file