You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Dmitry Kuleshov (JIRA)" <ji...@apache.org> on 2012/08/20 11:55:37 UTC

[jira] [Created] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Dmitry Kuleshov created JCR-3413:
------------------------------------

             Summary: Query with CONTAINS OR LIKE expression returns malformed result
                 Key: JCR-3413
                 URL: https://issues.apache.org/jira/browse/JCR-3413
             Project: Jackrabbit Content Repository
          Issue Type: Bug
          Components: jackrabbit-core
            Reporter: Dmitry Kuleshov


Seems that JCR-SQL queries with {{CONTAINS OR LIKE}} expressions return malformed results. 
The behavior is like {{AND}} operator is used to evaluate the results, though {{OR}} operator is mentioned in the query.

To simplify The following test is failing
{code:java}
   public void testLikeOrContainsClauses() throws Exception
   {
      Node foo = testRootNode.addNode("foo");
      foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});

      Node foo2 = testRootNode.addNode("foo2");
      foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});

      testRootNode.save();

      String sql =
         "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
      Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      QueryResult result = q.execute();
      checkResult(result, 0);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 2);
   }
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Dmitry Kuleshov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dmitry Kuleshov updated JCR-3413:
---------------------------------

    Description: 
Seems that JCR-SQL queries with {{CONTAINS OR LIKE}} expressions return malformed results. 
The behavior is like {{AND}} operator is used to evaluate the results, though {{OR}} operator is mentioned in the query.

To simplify The following test is failing:

   public void testLikeOrContainsClauses() throws Exception
   {
      Node foo = testRootNode.addNode("foo");
      foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});

      Node foo2 = testRootNode.addNode("foo2");
      foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});

      testRootNode.save();

      String sql =
         "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
      Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      QueryResult result = q.execute();
      checkResult(result, 0);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 2);
   }


  was:
Seems that JCR-SQL queries with {{CONTAINS OR LIKE}} expressions return malformed results. 
The behavior is like {{AND}} operator is used to evaluate the results, though {{OR}} operator is mentioned in the query.

To simplify The following test is failing
{code}
   public void testLikeOrContainsClauses() throws Exception
   {
      Node foo = testRootNode.addNode("foo");
      foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});

      Node foo2 = testRootNode.addNode("foo2");
      foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});

      testRootNode.save();

      String sql =
         "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
      Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      QueryResult result = q.execute();
      checkResult(result, 0);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 2);
   }
{code}

    
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>
> Seems that JCR-SQL queries with {{CONTAINS OR LIKE}} expressions return malformed results. 
> The behavior is like {{AND}} operator is used to evaluate the results, though {{OR}} operator is mentioned in the query.
> To simplify The following test is failing:
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Alexander Klimetschek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437777#comment-13437777 ] 

Alexander Klimetschek commented on JCR-3413:
--------------------------------------------

What exactly is failing and what are the results?

(It would be optimal if you'd put the raw query, the content structure and the actual vs. unexpected results in the description and attach the full test case as a file)
                
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>
> Seems that JCR-SQL queries with CONTAINS OR LIKE expressions return malformed results. 
> The behavior is like AND operator is used to evaluate the results, though OR operator is mentioned in the query.
> To simplify The following test is failing:
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Dmitry Kuleshov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437884#comment-13437884 ] 

Dmitry Kuleshov commented on JCR-3413:
--------------------------------------

Do you mean that support of such kind of queries is optional in JCR-SQL according to JCR 1.0 spec: http://www.day.com/specs/jcr/1.0/8.5.2.6_Joins.html ?
                
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>         Attachments: LikeOrContainsTest.java
>
>
> Seems that JCR-SQL queries with CONTAINS OR LIKE expressions return malformed results. 
> The behavior is like AND operator is used to evaluate the results, though OR operator is mentioned in the query.
> To simplify The following test is failing:
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Dmitry Kuleshov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dmitry Kuleshov updated JCR-3413:
---------------------------------

    Attachment: LikeOrContainsTest.java

Greeteings Alexander,

In the test I've just attached I have the following situation:
I create two nodes named "foo" and "foo2" correspondingly.

Testcase 1.
Execution of 
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'" 
results in 0 nodes and this is the expected result for obvious reasons.

Testcase 2.
Execution of 
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
results in 1 node and this is correct too, becuase only one node contains 'fox' text.

Testcase 3. 
Execution of
  "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
results in 1 node and this is also correct, because only one node have the name "foo2".

Testcase 4.
Exectution of
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'"
results in 0 nodes and in my opinion this seems to be incorrect, beacuse this query is logical addition of testcase 2 and testcase 3 queries.
The result should be both nodes: the first because it contains "fox" in text field and the second because its name is "foo2".

However I should also admit that "CONTAINS OR CONTAINS" and "LIKE OR LIKE" queries seems to work fine.
                
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>         Attachments: LikeOrContainsTest.java
>
>
> Seems that JCR-SQL queries with CONTAINS OR LIKE expressions return malformed results. 
> The behavior is like AND operator is used to evaluate the results, though OR operator is mentioned in the query.
> To simplify The following test is failing:
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Alexander Klimetschek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437809#comment-13437809 ] 

Alexander Klimetschek commented on JCR-3413:
--------------------------------------------

AFAICS, this is a JOIN-style query that is not supported by JCR-SQL or Xpath. Have a look at SQL2 from the JCR 2.0 spec which supports JOINS.
                
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>         Attachments: LikeOrContainsTest.java
>
>
> Seems that JCR-SQL queries with CONTAINS OR LIKE expressions return malformed results. 
> The behavior is like AND operator is used to evaluate the results, though OR operator is mentioned in the query.
> To simplify The following test is failing:
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Comment Edited] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Dmitry Kuleshov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437884#comment-13437884 ] 

Dmitry Kuleshov edited comment on JCR-3413 at 8/21/12 1:14 AM:
---------------------------------------------------------------

Do you mean that support of such kind of queries is optional in JCR-SQL according to JCR 1.0 spec: http://www.day.com/specs/jcr/1.0/8.5.2.6_Joins.html ?

If so than I guess there is nothing to do more with this issue
                
      was (Author: dkuleshov):
    Do you mean that support of such kind of queries is optional in JCR-SQL according to JCR 1.0 spec: http://www.day.com/specs/jcr/1.0/8.5.2.6_Joins.html ?
                  
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>         Attachments: LikeOrContainsTest.java
>
>
> Seems that JCR-SQL queries with CONTAINS OR LIKE expressions return malformed results. 
> The behavior is like AND operator is used to evaluate the results, though OR operator is mentioned in the query.
> To simplify The following test is failing:
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Comment Edited] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Dmitry Kuleshov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437797#comment-13437797 ] 

Dmitry Kuleshov edited comment on JCR-3413 at 8/20/12 10:39 PM:
----------------------------------------------------------------

Greeteings Alexander,

In the test I've just attached I have the following situation:
I create two nodes named "foo" and "foo2" correspondingly.

Testcase 1.
Execution of 
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'" 
results in 0 nodes and this is the expected result for obvious reasons.

Testcase 2.
Execution of 
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
results in 1 node and this is correct too, becuase the only one node contains 'fox' text.

Testcase 3. 
Execution of
  "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
results in 1 node and this is also correct, because the only one node has the name "foo2".

Testcase 4.
Exectution of
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'"
results in 0 nodes and in my opinion this seems to be incorrect, beacuse this query is logical addition of testcase 2 and testcase 3 queries.
The result should be both nodes: the first because it contains "fox" in text field and the second because its name is "foo2".

However I should also admit that "CONTAINS OR CONTAINS" and "LIKE OR LIKE" queries seem to work fine.
                
      was (Author: dkuleshov):
    Greeteings Alexander,

In the test I've just attached I have the following situation:
I create two nodes named "foo" and "foo2" correspondingly.

Testcase 1.
Execution of 
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'" 
results in 0 nodes and this is the expected result for obvious reasons.

Testcase 2.
Execution of 
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
results in 1 node and this is correct too, becuase the only one node contains 'fox' text.

Testcase 3. 
Execution of
  "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
results in 1 node and this is also correct, because the only one node has the name "foo2".

Testcase 4.
Exectution of
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'"
results in 0 nodes and in my opinion this seems to be incorrect, beacuse this query is logical addition of testcase 2 and testcase 3 queries.
The result should be both nodes: the first because it contains "fox" in text field and the second because its name is "foo2".

However I should also admit that "CONTAINS OR CONTAINS" and "LIKE OR LIKE" queries seems to work fine.
                  
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>         Attachments: LikeOrContainsTest.java
>
>
> Seems that JCR-SQL queries with CONTAINS OR LIKE expressions return malformed results. 
> The behavior is like AND operator is used to evaluate the results, though OR operator is mentioned in the query.
> To simplify The following test is failing:
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Comment Edited] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Dmitry Kuleshov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437797#comment-13437797 ] 

Dmitry Kuleshov edited comment on JCR-3413 at 8/20/12 10:38 PM:
----------------------------------------------------------------

Greeteings Alexander,

In the test I've just attached I have the following situation:
I create two nodes named "foo" and "foo2" correspondingly.

Testcase 1.
Execution of 
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'" 
results in 0 nodes and this is the expected result for obvious reasons.

Testcase 2.
Execution of 
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
results in 1 node and this is correct too, becuase the only one node contains 'fox' text.

Testcase 3. 
Execution of
  "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
results in 1 node and this is also correct, because the only one node has the name "foo2".

Testcase 4.
Exectution of
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'"
results in 0 nodes and in my opinion this seems to be incorrect, beacuse this query is logical addition of testcase 2 and testcase 3 queries.
The result should be both nodes: the first because it contains "fox" in text field and the second because its name is "foo2".

However I should also admit that "CONTAINS OR CONTAINS" and "LIKE OR LIKE" queries seems to work fine.
                
      was (Author: dkuleshov):
    Greeteings Alexander,

In the test I've just attached I have the following situation:
I create two nodes named "foo" and "foo2" correspondingly.

Testcase 1.
Execution of 
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'" 
results in 0 nodes and this is the expected result for obvious reasons.

Testcase 2.
Execution of 
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
results in 1 node and this is correct too, becuase only one node contains 'fox' text.

Testcase 3. 
Execution of
  "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
results in 1 node and this is also correct, because only one node have the name "foo2".

Testcase 4.
Exectution of
  "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'"
results in 0 nodes and in my opinion this seems to be incorrect, beacuse this query is logical addition of testcase 2 and testcase 3 queries.
The result should be both nodes: the first because it contains "fox" in text field and the second because its name is "foo2".

However I should also admit that "CONTAINS OR CONTAINS" and "LIKE OR LIKE" queries seems to work fine.
                  
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>         Attachments: LikeOrContainsTest.java
>
>
> Seems that JCR-SQL queries with CONTAINS OR LIKE expressions return malformed results. 
> The behavior is like AND operator is used to evaluate the results, though OR operator is mentioned in the query.
> To simplify The following test is failing:
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Randall Hauch (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437932#comment-13437932 ] 

Randall Hauch commented on JCR-3413:
------------------------------------

None of these are JOIN queries, since they all involve a single selector in the FROM clause. They all appear to be valid per the JCR 1.0 specification that covers the JCR-SQL language. And this query:

  SELECT * FROM nt:unstructured WHERE contains(., 'fox') OR jcr:path LIKE '" + testRoot + "/foo2'

should return both nodes referenced by the 'foo' and 'foo2' variables.
                
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>         Attachments: LikeOrContainsTest.java
>
>
> Seems that JCR-SQL queries with CONTAINS OR LIKE expressions return malformed results. 
> The behavior is like AND operator is used to evaluate the results, though OR operator is mentioned in the query.
> To simplify The following test is failing:
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Dmitry Kuleshov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dmitry Kuleshov updated JCR-3413:
---------------------------------

    Description: 
Seems that JCR-SQL queries with {{CONTAINS OR LIKE}} expressions return malformed results. 
The behavior is like {{AND}} operator is used to evaluate the results, though {{OR}} operator is mentioned in the query.

To simplify The following test is failing
{code}
   public void testLikeOrContainsClauses() throws Exception
   {
      Node foo = testRootNode.addNode("foo");
      foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});

      Node foo2 = testRootNode.addNode("foo2");
      foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});

      testRootNode.save();

      String sql =
         "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
      Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      QueryResult result = q.execute();
      checkResult(result, 0);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 2);
   }
{code}

  was:
Seems that JCR-SQL queries with {{CONTAINS OR LIKE}} expressions return malformed results. 
The behavior is like {{AND}} operator is used to evaluate the results, though {{OR}} operator is mentioned in the query.

To simplify The following test is failing
{code:java}
   public void testLikeOrContainsClauses() throws Exception
   {
      Node foo = testRootNode.addNode("foo");
      foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});

      Node foo2 = testRootNode.addNode("foo2");
      foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});

      testRootNode.save();

      String sql =
         "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
      Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      QueryResult result = q.execute();
      checkResult(result, 0);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 2);
   }
{code}

    
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>
> Seems that JCR-SQL queries with {{CONTAINS OR LIKE}} expressions return malformed results. 
> The behavior is like {{AND}} operator is used to evaluate the results, though {{OR}} operator is mentioned in the query.
> To simplify The following test is failing
> {code}
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Alexander Klimetschek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437948#comment-13437948 ] 

Alexander Klimetschek commented on JCR-3413:
--------------------------------------------

JCR-SQL and Xpath share the same implementation and anything path-based is considered a join (in xpath the query would be a join).

The spec mentions that jcr:path is a special property that is calculated on demand at the end of a query: http://www.day.com/specs/jcr/1.0/8.5.2.2_Pseudo-property_jcr_path.html "Such an approach would be advantageous for those implementations in which path calculation is expensive." Jackrabbit's index and (1.0) query engine is such a case (paths are not indexed).
                
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>         Attachments: LikeOrContainsTest.java
>
>
> Seems that JCR-SQL queries with CONTAINS OR LIKE expressions return malformed results. 
> The behavior is like AND operator is used to evaluate the results, though OR operator is mentioned in the query.
> To simplify The following test is failing:
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Dmitry Kuleshov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dmitry Kuleshov updated JCR-3413:
---------------------------------

    Description: 
Seems that JCR-SQL queries with CONTAINS OR LIKE expressions return malformed results. 
The behavior is like AND operator is used to evaluate the results, though OR operator is mentioned in the query.

To simplify The following test is failing:

   public void testLikeOrContainsClauses() throws Exception
   {
      Node foo = testRootNode.addNode("foo");
      foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});

      Node foo2 = testRootNode.addNode("foo2");
      foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});

      testRootNode.save();

      String sql =
         "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
      Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      QueryResult result = q.execute();
      checkResult(result, 0);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 2);
   }


  was:
Seems that JCR-SQL queries with {{CONTAINS OR LIKE}} expressions return malformed results. 
The behavior is like {{AND}} operator is used to evaluate the results, though {{OR}} operator is mentioned in the query.

To simplify The following test is failing:

   public void testLikeOrContainsClauses() throws Exception
   {
      Node foo = testRootNode.addNode("foo");
      foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});

      Node foo2 = testRootNode.addNode("foo2");
      foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});

      testRootNode.save();

      String sql =
         "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
      Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      QueryResult result = q.execute();
      checkResult(result, 0);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 1);

      sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
      q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
      result = q.execute();
      checkResult(result, 2);
   }


    
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>
> Seems that JCR-SQL queries with CONTAINS OR LIKE expressions return malformed results. 
> The behavior is like AND operator is used to evaluate the results, though OR operator is mentioned in the query.
> To simplify The following test is failing:
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result

Posted by "Marcel Reutegger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marcel Reutegger resolved JCR-3413.
-----------------------------------

    Resolution: Won't Fix

This kind of query with a jcr:path ORed together with the rest of constraint is not supported in Jackrabbit.
                
> Query with CONTAINS OR LIKE expression returns malformed result
> ---------------------------------------------------------------
>
>                 Key: JCR-3413
>                 URL: https://issues.apache.org/jira/browse/JCR-3413
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>            Reporter: Dmitry Kuleshov
>         Attachments: LikeOrContainsTest.java
>
>
> Seems that JCR-SQL queries with CONTAINS OR LIKE expressions return malformed results. 
> The behavior is like AND operator is used to evaluate the results, though OR operator is mentioned in the query.
> To simplify The following test is failing:
>    public void testLikeOrContainsClauses() throws Exception
>    {
>       Node foo = testRootNode.addNode("foo");
>       foo.setProperty("mytext", new String[]{"the quick brown fox jumps over the lazy dog."});
>       Node foo2 = testRootNode.addNode("foo2");
>       foo2.setProperty("mytext", new String[]{"the quick brown dinosaur jumps over the lazy dog."});
>       testRootNode.save();
>       String sql =
>          "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "AND jcr:path LIKE '" + testRoot + "/foo2'";
>       Query q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       QueryResult result = q.execute();
>       checkResult(result, 0);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') ";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 1);
>       sql = "SELECT * FROM nt:unstructured WHERE contains(., 'fox') " + "OR jcr:path LIKE '" + testRoot + "/foo2'";
>       q = superuser.getWorkspace().getQueryManager().createQuery(sql, Query.SQL);
>       result = q.execute();
>       checkResult(result, 2);
>    }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira