[ 
https://issues.apache.org/jira/browse/OAK-4313?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15258249#comment-15258249
 ] 

Vikas Saurabh commented on OAK-4313:
------------------------------------

I think {{SuggestImpl}} and {{SpellcheckImpl}} should throw in {{evaluate()}} 
just as {{SimilarImpl}} does. Something like:
{noformat}
diff --git 
a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SpellcheckImpl.java
 
b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SpellcheckImpl.java
index b4bdedc..51ed7bf 100644
--- 
a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SpellcheckImpl.java
+++ 
b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SpellcheckImpl.java
@@ -66,8 +66,7 @@ public class SpellcheckImpl extends ConstraintImpl {
         // and because we don't know how to process native
         // conditions
         if (!(selector.getIndex() instanceof FulltextQueryIndex)) {
-            log.warn("No full-text index was found that can process the 
condition " + toString());
-            return false;
+            throw new IllegalArgumentException("No full-text index was found 
that can process the condition " + toString());
         }
         // we assume the index only returns the requested entries
         return true;
diff --git 
a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SuggestImpl.java 
b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SuggestImpl.java
index fc04c40..4a4605a 100644
--- 
a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SuggestImpl.java
+++ 
b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/SuggestImpl.java
@@ -66,8 +66,7 @@ public class SuggestImpl extends ConstraintImpl {
         // and because we don't know how to process native
         // conditions
         if (!(selector.getIndex() instanceof FulltextQueryIndex)) {
-            log.warn("No full-text index was found that can process the 
condition " + toString());
-            return false;
+            throw new IllegalArgumentException("No full-text index was found 
that can process the condition " + toString());
         }
         // we assume the index only returns the requested entries
         return true;
{noformat}

I'm still trying to figure out how to test 'avoid repository scan'. I would 
want to avoid asserting 'an exception is expected in 
{{QueryResult.getRows()}}'. [~tmueller] thought?

(cc [~teofili]).

> Query can scan whole repository for suggestion/spellcheck query when no index 
> supports those constraints
> --------------------------------------------------------------------------------------------------------
>
>                 Key: OAK-4313
>                 URL: https://issues.apache.org/jira/browse/OAK-4313
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: lucene
>            Reporter: Vikas Saurabh
>            Assignee: Vikas Saurabh
>              Labels: candidate_oak_1_2, candidate_oak_1_4
>             Fix For: 1.6
>
>
> If no index supports suggestion (or spellcheck) query, then a query like
> {noformat}
> SELECT * from [nt:base] where SUGGEST('test')
> {noformat}
> would pick {{TraversingCursor}} where each row currently evaluates to false 
> and hence a whole repo scan.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to