You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by eh...@apache.org on 2005/11/24 10:09:57 UTC
svn commit: r348692 - in /lucene/java/trunk/src:
java/org/apache/lucene/search/regex/RegexTermEnum.java
test/org/apache/lucene/search/regex/TestRegexQuery.java
Author: ehatcher
Date: Thu Nov 24 01:09:48 2005
New Revision: 348692
URL: http://svn.apache.org/viewcvs?rev=348692&view=rev
Log:
Modified RegexTermEnum to have more generic logic, Character.isLetterOrDigit(), to determine the prefix for term enumeration.
Also added commented out test demonstrating where prefix logic fails currently. Perhaps, like FuzzyQuery, we should push the
prefix calculation back to the user of the query for now?
Modified:
lucene/java/trunk/src/java/org/apache/lucene/search/regex/RegexTermEnum.java
lucene/java/trunk/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/regex/RegexTermEnum.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/regex/RegexTermEnum.java?rev=348692&r1=348691&r2=348692&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/regex/RegexTermEnum.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/regex/RegexTermEnum.java Thu Nov 24 01:09:48 2005
@@ -26,9 +26,7 @@
while (index < text.length()) {
char c = text.charAt(index);
- // TODO: improve the logic here. There are other types of patterns
- // that could break this, such as "\d*" and "\*abc"
- if (c == '*' || c == '[' || c == '?' || c == '.') break;
+ if (!Character.isLetterOrDigit(c)) break;
index++;
}
Modified: lucene/java/trunk/src/test/org/apache/lucene/search/regex/TestRegexQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/regex/TestRegexQuery.java?rev=348692&r1=348691&r2=348692&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/regex/TestRegexQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/regex/TestRegexQuery.java Thu Nov 24 01:09:48 2005
@@ -89,5 +89,12 @@
public void testSpanRegex2() throws Exception {
assertEquals(0, spanRegexQueryNrHits("q.[aeiou]c.*", "dog", 5, true));
}
+
+// public void testPrefix() throws Exception {
+ // This test currently fails because RegexTermEnum picks "r" as the prefix
+ // but the following "?" makes the "r" optional and should be a hit for the
+ // document matching "over".
+// assertEquals(1, regexQueryNrHits("r?over"));
+// }
}