[jsword-svn] r2069 - in trunk/jsword/src/main/java/org/crosswire/jsword: examples index/lucene
dmsmith at crosswire.org
dmsmith at crosswire.org
Tue Jan 4 10:41:37 MST 2011
Author: dmsmith
Date: 2011-01-04 10:41:37 -0700 (Tue, 04 Jan 2011)
New Revision: 2069
Modified:
trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java
trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneSearcher.java
Log:
JS-156 API Examples has an OOM exception for ranked searches and does not properly check for trimVerses results.
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java 2011-01-01 23:53:21 UTC (rev 2068)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/examples/APIExamples.java 2011-01-04 17:41:37 UTC (rev 2069)
@@ -219,7 +219,11 @@
if (key instanceof Passage) {
Passage remaining = ((Passage) key).trimVerses(5);
System.out.println("The first 5 verses containing both moses and aaron: " + key.getName());
- System.out.println("The rest of the verses are: " + remaining.getName());
+ if (remaining != null) {
+ System.out.println("The rest of the verses are: " + remaining.getName());
+ } else {
+ System.out.println("There are only 5 verses containing both moses and aaron");
+ }
}
}
@@ -234,9 +238,11 @@
// For a more complex example:
// Rank the verses and show the first 20
boolean rank = true;
+ int max = 20;
DefaultSearchModifier modifier = new DefaultSearchModifier();
modifier.setRanked(rank);
+ modifier.setMaxResults(max);
Key results = bible.find(new DefaultSearchRequest("for god so loved the world", modifier));
int total = results.getCardinality();
@@ -246,7 +252,7 @@
if (results instanceof PassageTally || rank) {
PassageTally tally = (PassageTally) results;
tally.setOrdering(PassageTally.ORDER_TALLY);
- int rankCount = 20;
+ int rankCount = max;
if (rankCount > 0 && rankCount < total) {
// Here we are trimming by ranges, where a range is a set of
// continuous verses.
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneSearcher.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneSearcher.java 2011-01-01 23:53:21 UTC (rev 2068)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/index/lucene/LuceneSearcher.java 2011-01-04 17:41:37 UTC (rev 2069)
@@ -33,7 +33,7 @@
/**
* The central interface to all searching.
*
- * Functionality the I invisage includes:
+ * Functionality the I envisage includes:
* <ul>
* <li>A simple search syntax that goes something like this.
* <ul>
More information about the jsword-svn
mailing list