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 ng...@apache.org on 2022/07/29 12:56:35 UTC

[jackrabbit-oak] branch trunk updated: Revert "OAK-9870 | Escaping brackets to avoid query parse exceptions (#643)"

This is an automated email from the ASF dual-hosted git repository.

ngupta pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git


The following commit(s) were added to refs/heads/trunk by this push:
     new e71d4f1fd5 Revert "OAK-9870 | Escaping brackets to avoid query parse exceptions (#643)"
e71d4f1fd5 is described below

commit e71d4f1fd5ef5eeb1cbc238646c9c465af74e631
Author: Nitin Gupta <ni...@adobe.com>
AuthorDate: Fri Jul 29 18:26:17 2022 +0530

    Revert "OAK-9870 | Escaping brackets to avoid query parse exceptions (#643)"
    
    This reverts commit c194a0d7547d6e5d6da4a5df0ab9e1efd647c2f5.
---
 .../index/search/spi/query/FulltextIndex.java      |  5 ++--
 .../oak/plugins/index/FullTextIndexCommonTest.java | 30 ----------------------
 2 files changed, 2 insertions(+), 33 deletions(-)

diff --git a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/FulltextIndex.java b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/FulltextIndex.java
index 56edd3d635..fb61936f8c 100644
--- a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/FulltextIndex.java
+++ b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/FulltextIndex.java
@@ -281,15 +281,14 @@ public abstract class FulltextIndex implements AdvancedQueryIndex, QueryIndex, N
     }
 
     /**
-     * Following chars are used as operators in Lucene and Elastic Queries and should be escaped
+     * Following chars are used as operators in Lucene Query and should be escaped
      */
-    private static final char[] QUERY_OPERATORS = {':' , '/', '!', '&', '|', '=', '{', '}', '[', ']', '(', ')'};
+    private static final char[] QUERY_OPERATORS = {':' , '/', '!', '&', '|', '='};
 
     /**
      * Following logic is taken from org.apache.jackrabbit.core.query.lucene.JackrabbitQueryParser#parse(java.lang.String)
      */
     public static String rewriteQueryText(String textsearch) {
-
         // replace escaped ' with just '
         StringBuilder rewritten = new StringBuilder();
         // most query parsers recognize 'AND' and 'NOT' as
diff --git a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/FullTextIndexCommonTest.java b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/FullTextIndexCommonTest.java
index f9851ec783..c60d348af9 100644
--- a/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/FullTextIndexCommonTest.java
+++ b/oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/FullTextIndexCommonTest.java
@@ -88,34 +88,4 @@ public abstract class FullTextIndexCommonTest extends AbstractQueryTest {
         });
     }
 
-
-    @Test
-    public void testWithSpecialCharsInSearchTerm() throws Exception {
-        IndexDefinitionBuilder builder = indexOptions.createIndex(
-                indexOptions.createIndexDefinitionBuilder(), false, "analyzed_field");
-        builder.noAsync();
-        builder.indexRule("nt:base")
-                .property("analyzed_field")
-                .analyzed().nodeScopeIndex();
-
-        indexOptions.setIndex(root, UUID.randomUUID().toString(), builder);
-        root.commit();
-
-        //add content
-        Tree test = root.getTree("/").addChild("test");
-
-        test.addChild("a").setProperty("analyzed_field", "foo");
-        root.commit();
-
-        assertEventually(() -> {
-            assertQuery("//*[jcr:contains(@analyzed_field, '{foo}')] ", XPATH, Collections.singletonList("/test/a"));
-            assertQuery("//*[jcr:contains(@analyzed_field, '\\{foo}')] ", XPATH, Collections.singletonList("/test/a"));
-            assertQuery("//*[jcr:contains(@analyzed_field, 'foo:')] ", XPATH, Collections.singletonList("/test/a"));
-            assertQuery("//*[jcr:contains(@analyzed_field, '[foo]')] ", XPATH, Collections.singletonList("/test/a"));
-            assertQuery("//*[jcr:contains(@analyzed_field, '|foo/')] ", XPATH, Collections.singletonList("/test/a"));
-            assertQuery("//*[jcr:contains(@analyzed_field, '(&=!foo')] ", XPATH, Collections.singletonList("/test/a"));
-        });
-
-    }
-
 }