You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ca...@apache.org on 2016/04/27 23:05:51 UTC

svn commit: r1741339 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/query/ast/ test/resources/org/apache/jackrabbit/oak/query/

Author: catholicon
Date: Wed Apr 27 21:05:50 2016
New Revision: 1741339

URL: http://svn.apache.org/viewvc?rev=1741339&view=rev
Log:
OAK-4317: Similar and Native queries should return no results if no index can handle them

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NativeFunctionImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SimilarImpl.java
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_native.txt

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NativeFunctionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NativeFunctionImpl.java?rev=1741339&r1=1741338&r2=1741339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NativeFunctionImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/NativeFunctionImpl.java Wed Apr 27 21:05:50 2016
@@ -23,6 +23,8 @@ import java.util.Set;
 
 import org.apache.jackrabbit.oak.api.PropertyValue;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import static org.apache.jackrabbit.oak.spi.query.QueryIndex.NativeQueryIndex;
 
@@ -30,7 +32,9 @@ import static org.apache.jackrabbit.oak.
  * A native function condition.
  */
 public class NativeFunctionImpl extends ConstraintImpl {
-    
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
     public static final String NATIVE_PREFIX = "native*";
     
     private final String selectorName;
@@ -63,7 +67,8 @@ public class NativeFunctionImpl extends
         // and because we don't know how to process native
         // conditions
         if (!(selector.getIndex() instanceof NativeQueryIndex)) {
-            throw new IllegalArgumentException("No full-text index was found that can process the condition " + toString());
+            log.warn("No full-text index was found that can process the condition " + toString());
+            return false;
         }
         // we assume the index only returns the requested entries
         return true;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SimilarImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SimilarImpl.java?rev=1741339&r1=1741338&r2=1741339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SimilarImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SimilarImpl.java Wed Apr 27 21:05:50 2016
@@ -26,12 +26,16 @@ import org.apache.jackrabbit.oak.api.Typ
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
 import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.oak.spi.query.QueryIndex.FulltextQueryIndex;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Support for "similar(...)
  */
 public class SimilarImpl extends ConstraintImpl {
-    
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
     public static final String NATIVE_LUCENE_LANGUAGE = "lucene";
     
     public static final String MORE_LIKE_THIS_PREFIX = "mlt?mlt.fl=:path&mlt.mindf=0&stream.body=";
@@ -67,7 +71,8 @@ public class SimilarImpl extends Constra
         // and because we don't know how to process native
         // conditions
         if (!(selector.getIndex() instanceof FulltextQueryIndex)) {
-            throw new IllegalArgumentException("No full-text index was found that can process the condition " + toString());
+            log.warn("No full-text index was found that can process the condition " + toString());
+            return false;
         }
         // verify the path is readable
         PropertyValue p = pathExpression.currentValue();

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_native.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_native.txt?rev=1741339&r1=1741338&r2=1741339&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_native.txt (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2_native.txt Wed Apr 27 21:05:50 2016
@@ -28,15 +28,12 @@ commit / + "test": { "a": { "name": "Hel
 
 select [jcr:path] from [nt:base]
   where native('solr', 'name:(Hello OR World)')
-java.lang.IllegalArgumentException: No full-text index was found that can process the condition native([nt:base], [solr], 'name:(Hello OR World)')
 
 select [jcr:path] from [nt:base] as a
   where native(a, 'solr', 'path_child:\/test _val_:"recip(rord(name),1,2,3)"')
-java.lang.IllegalArgumentException: No full-text index was found that can process the condition native([a], [solr], 'path_child:\/test _val_:"recip(rord(name),1,2,3)"')
 
 select [jcr:path] from [nt:base]
   where native('solr', 'path_child:\/test _val_:"recip(rord(name),1,2,3)"')
-java.lang.IllegalArgumentException: No full-text index was found that can process the condition native([nt:base], [solr], 'path_child:\/test _val_:"recip(rord(name),1,2,3)"')
 
 xpath2sql //*[rep:native('solr', 'xyz')]
 select [jcr:path], [jcr:score], *