lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r799678 - in /lucene/java/trunk/contrib: CHANGES.txt regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
Date Fri, 31 Jul 2009 18:02:56 GMT
Author: mikemccand
Date: Fri Jul 31 18:02:56 2009
New Revision: 799678

URL: http://svn.apache.org/viewvc?rev=799678&view=rev
Log:
LUCENE-1683: fixed JavaUtilRegexCapabilities (used by RegexQuery) to match entire string not
just prefix

Modified:
    lucene/java/trunk/contrib/CHANGES.txt
    lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java
    lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java

Modified: lucene/java/trunk/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/CHANGES.txt?rev=799678&r1=799677&r2=799678&view=diff
==============================================================================
--- lucene/java/trunk/contrib/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/CHANGES.txt Fri Jul 31 18:02:56 2009
@@ -47,6 +47,11 @@
  8. LUCENE-1491: EdgeNGramTokenFilter no longer stops on tokens shorter than minimum n-gram
size.
     (Todd Teak via Otis Gospodnetic)
 
+ 9. LUCENE-1683: Fixed JavaUtilRegexCapabilities (an impl used by
+    RegexQuery) to use Matcher.matches() not Matcher.lookingAt() so
+    that the regexp must match the entire string, not just a prefix.
+    (Trejkaz via Mike McCandless)
+
 New features
 
  1. LUCENE-1531: Added support for BoostingTermQuery to XML query parser. (Karl Wettin)

Modified: lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java?rev=799678&r1=799677&r2=799678&view=diff
==============================================================================
--- lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java
(original)
+++ lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java
Fri Jul 31 18:02:56 2009
@@ -71,7 +71,7 @@
   }
 
   public boolean match(String string) {
-    return pattern.matcher(string).lookingAt();
+    return pattern.matcher(string).matches();
   }
 
   public String prefix() {

Modified: lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java?rev=799678&r1=799677&r2=799678&view=diff
==============================================================================
--- lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
(original)
+++ lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
Fri Jul 31 18:02:56 2009
@@ -25,6 +25,7 @@
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.index.TermEnum;
 
 import org.apache.lucene.search.spans.SpanNearQuery;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -77,6 +78,13 @@
     return searcher.search(query).length();
   }
 
+  public void testMatchAll() throws Exception {
+    TermEnum terms = new RegexQuery(new Term(FN, "jum.")).getEnum(searcher.getIndexReader());
+    // no term should match
+    assertNull(terms.term());
+    assertFalse(terms.next());
+  }
+
   public void testRegex1() throws Exception {
     assertEquals(1, regexQueryNrHits("^q.[aeiou]c.*$", null));
   }



Mime
View raw message