jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1393951 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java
Date Thu, 04 Oct 2012 08:16:35 GMT
Author: alexparvulescu
Date: Thu Oct  4 08:16:35 2012
New Revision: 1393951

URL: http://svn.apache.org/viewvc?rev=1393951&view=rev
Log:
OAK-347 QueryEngine 'like' interpretation error
 - support for '%' queries

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java?rev=1393951&r1=1393950&r2=1393951&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/lucene/LuceneIndex.java
Thu Oct  4 08:16:35 2012
@@ -205,10 +205,14 @@ public class LuceneIndex implements Quer
             }
 
             if (isLike) {
-                if (first.contains("%")) {
-                    first = first.replace("%", "*");
-                }
-                if (first.endsWith("*")) {
+                first = first.replace('%', WildcardQuery.WILDCARD_STRING);
+                first = first.replace('_', WildcardQuery.WILDCARD_CHAR);
+
+                int indexOfWS = first.indexOf(WildcardQuery.WILDCARD_STRING);
+                int indexOfWC = first.indexOf(WildcardQuery.WILDCARD_CHAR);
+                int len = first.length();
+
+                if (indexOfWS == len || indexOfWC == len) {
                     // remove trailing "*" for prefixquery
                     first = first.substring(0, first.length() - 1);
                     if (JCR_PATH.equals(name)) {



Mime
View raw message