Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

Updated JakartaRegexpCapabilities JavaDoc which gave users the impression the JakartaRegexp implementation provides a rock solid "prefix" implementation. Patch contains another testcase which shows the shaky behavior. See LUCENE-2072 for reference.

Simon Willnauere077c4d563d4
diff --git a/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java b/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java
index 9c69bb9b78c..3e7c4298e19 100644
--- a/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java
+++ b/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java
@@ -21,9 +21,11 @@ import org.apache.regexp.RE;
import org.apache.regexp.RegexpTunnel;
/**
- * Implementation tying <a href="http://jakarta.apache.org/regexp">Jakarta Regexp</a>
- * to RegexQuery. Thanks to some internals of Jakarta Regexp, this
- * has a solid {@link #prefix} implementation.
+ * Implementation tying <a href="http://jakarta.apache.org/regexp">Jakarta
+ * Regexp</a> to RegexQuery. Jakarta Regepx internally supports a
+ * {@link #prefix} implementation which can offer performance gains under
+ * certain circumstances. Yet, the implementation appears to be rather shaky as
+ * it doesn't always provide a prefix even if one would exist.
*/
public class JakartaRegexpCapabilities implements RegexCapabilities {
private RE regexp;
diff --git a/contrib/regex/src/test/org/apache/lucene/search/regex/TestJakartaRegexpCapabilities.java b/contrib/regex/src/test/org/apache/lucene/search/regex/TestJakartaRegexpCapabilities.java
index d5552bc938d..e9ca88dc9c0 100644
--- a/contrib/regex/src/test/org/apache/lucene/search/regex/TestJakartaRegexpCapabilities.java
+++ b/contrib/regex/src/test/org/apache/lucene/search/regex/TestJakartaRegexpCapabilities.java
@@ -34,4 +34,13 @@ public class TestJakartaRegexpCapabilities extends TestCase {
assertTrue(cap.match("lucene"));
assertEquals("lucene", cap.prefix());
}
+
+ public void testShakyPrefix(){
+ JakartaRegexpCapabilities cap = new JakartaRegexpCapabilities();
+ cap.compile("(ab|ac)");
+ assertTrue(cap.match("ab"));
+ assertTrue(cap.match("ac"));
+ // why is it not a???
+ assertNull(cap.prefix());
+ }
}