jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitry Kuleshov (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (JCR-3413) Query with CONTAINS OR LIKE expression returns malformed result
Date Mon, 20 Aug 2012 11:40:38 GMT

    [ 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

        

Mime
View raw message