Update of /var/cvs/contributions/natmm/src/nl/leocms/util/tools
In directory james.mmbase.org:/tmp/cvs-serv21395/src/nl/leocms/util/tools
Modified Files:
SearchUtil.java
Log Message:
NMCMS-575 - Also log the real error on Lucene search queries
See also:
http://cvs.mmbase.org/viewcvs/contributions/natmm/src/nl/leocms/util/tools
See also: http://www.mmbase.org/jira/browse/NMCMS-575
Index: SearchUtil.java
===================================================================
RCS file:
/var/cvs/contributions/natmm/src/nl/leocms/util/tools/SearchUtil.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- SearchUtil.java 21 Apr 2008 11:52:28 -0000 1.18
+++ SearchUtil.java 11 Sep 2008 11:36:42 -0000 1.19
@@ -25,7 +25,7 @@
* Utilities functions for the search pages
*
* @author H. Hangyi
- * @version $Revision: 1.18 $
+ * @version $Revision: 1.19 $
*/
public class SearchUtil {
@@ -306,7 +306,7 @@
try {
net.sf.mmapps.modules.lucenesearch.SearchIndex si = cf.getIndex(index);
Analyzer analyzer = si.getAnalyzer();
- IndexReader ir = IndexReader.open(si.getIndex());
+
QueryParser qp = new QueryParser("indexed.text", analyzer);
qp.setDefaultOperator(QueryParser.AND_OPERATOR);
org.apache.lucene.search.Query result = null;
@@ -322,8 +322,10 @@
BooleanQuery constructedQuery = new BooleanQuery();
constructedQuery.add(result, BooleanClause.Occur.MUST);
+ IndexReader ir = IndexReader.open(si.getIndex());
IndexSearcher searcher = new IndexSearcher(ir);
Hits hits = searcher.search(constructedQuery);
+
TreeSet includedEvents = new TreeSet();
for (int i = 0; i < hits.length(); i++) {
@@ -378,11 +380,14 @@
}
}
+ //Close resources when they are not needed anymore.
if(searcher!=null) { searcher.close(); }
if(ir!=null) { ir.close(); }
+
}
} catch (Exception e) {
log.error("lucene index " + index + " throws error on query " +
sQuery);
+ log.error(e); //Also log the specific error
}
return hsetNodes;
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs