mirror of https://github.com/apache/lucene.git
LUCENE-1683: fixed JavaUtilRegexCapabilities (used by RegexQuery) to match entire string not just prefix
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@799678 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0b0d13dffe
commit
bbcab117d9
|
@ -47,6 +47,11 @@ Bug fixes
|
|||
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)
|
||||
|
|
|
@ -71,7 +71,7 @@ public class JavaUtilRegexCapabilities implements RegexCapabilities {
|
|||
}
|
||||
|
||||
public boolean match(String string) {
|
||||
return pattern.matcher(string).lookingAt();
|
||||
return pattern.matcher(string).matches();
|
||||
}
|
||||
|
||||
public String prefix() {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.lucene.analysis.SimpleAnalyzer;
|
|||
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 @@ public class TestRegexQuery extends TestCase {
|
|||
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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue