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

Vikas Saurabh commented on OAK-4787:
------------------------------------

Proposed patch
{noformat}
diff --git 
a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/fulltext/FullTextParser.java
 
b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/fulltext/FullTextParser.java
index c76a954..a087a2a 100644
--- 
a/oak-core/src/main/java/org/apache/jackrabbit/oak/query/fulltext/FullTextParser.java
+++ 
b/oak-core/src/main/java/org/apache/jackrabbit/oak/query/fulltext/FullTextParser.java
@@ -162,7 +162,7 @@ public class FullTextParser {
                     }
                     c = text.charAt(parseIndex++);
                     buff.append(c);
-                } else if (c == '^') {
+                } else if (c == '^' && buff.length() > 0) {
                     boost = "";
                     break;
                 } else if (c <= ' ') {
diff --git 
a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/FullTextTest.java 
b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/FullTextTest.java
index bde63a8..f3ae0cf 100644
--- 
a/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/FullTextTest.java
+++ 
b/oak-core/src/test/java/org/apache/jackrabbit/oak/query/ast/FullTextTest.java
@@ -130,6 +130,13 @@ public class FullTextTest {
     }

     @Test
+    public void caratLiteral() throws ParseException {
+        assertTrue(test("h ^", "h ^"));
+        assertTrue(test("h ^ ", "h ^"));
+        assertTrue(test("h ^ 2", "h ^ 2"));
+    }
+
+    @Test
     public void invalid() throws ParseException {
         testInvalid("", "(*); expected: term");
         testInvalid("x OR ", "x OR(*); expected: term");
{noformat}
/cc [~tmueller]

> Fulltext parser should handle carat more gracefully
> ---------------------------------------------------
>
>                 Key: OAK-4787
>                 URL: https://issues.apache.org/jira/browse/OAK-4787
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: query
>            Reporter: Vikas Saurabh
>            Assignee: Vikas Saurabh
>            Priority: Minor
>
> During investigation of OAK-4705, we found that even carat ({{^}}) can lead 
> to parse exceptions when it could simply be included as a literal string.



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

Reply via email to