You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Vikas Saurabh (JIRA)" <ji...@apache.org> on 2016/02/09 17:40:18 UTC

[jira] [Commented] (OAK-1744) GQL queries with "jcr:primaryType='x'" don't use the node type index

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

Vikas Saurabh commented on OAK-1744:
------------------------------------

[~tmueller], after this change, following query fails with ParseException \[0]
{noformat}
/jcr:root/a/b/*[(@jcr:primaryType = 'nt:base' or @jcr:primaryType = 'nt:unstructured' or @jcr:primaryType = 'oak:Unstructured')]
{noformat}

Having 3 types is important. 2 types in or clauses work fine.


\[0]:
{noformat}
java.text.ParseException: /jcr:root/a/b/*[(@jcr:primaryType = 'nt:base' or @jcr:primaryType = 'nt:unstructured' or @jcr:primaryType = 'oak:Unstructured')] converted to SQL-2 Query: select [jcr:path], [jcr:score], * from [nt:base] as a where [jcr:primaryType] = 'nt:base' in(*)([jcr:primaryType] = 'nt:unstructured', 'oak:Unstructured') and ischildnode(a, '/a/b') /* xpath: /jcr:root/a/b/*[(@jcr:primaryType = 'nt:base' or @jcr:primaryType = 'nt:unstructured' or @jcr:primaryType = 'oak:Unstructured')] */; expected: <end>

    at org.apache.jackrabbit.oak.query.QueryEngineImpl.parseQuery(QueryEngineImpl.java:190)
    at org.apache.jackrabbit.oak.query.QueryEngineImpl.executeQuery(QueryEngineImpl.java:257)
    at org.apache.jackrabbit.oak.query.QueryEngineImpl.executeQuery(QueryEngineImpl.java:233)
    at org.apache.jackrabbit.oak.query.AbstractQueryTest.executeQuery(AbstractQueryTest.java:122)
    at org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexQueryTest.justChecking(LuceneIndexQueryTest.java:461)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.text.ParseException: Query: select [jcr:path], [jcr:score], * from [nt:base] as a where [jcr:primaryType] = 'nt:base' in(*)([jcr:primaryType] = 'nt:unstructured', 'oak:Unstructured') and ischildnode(a, '/a/b') /* xpath: /jcr:root/a/b/*[(@jcr:primaryType = 'nt:base' or @jcr:primaryType = 'nt:unstructured' or @jcr:primaryType = 'oak:Unstructured')] */; expected: <end>
    at org.apache.jackrabbit.oak.query.SQL2Parser.getSyntaxError(SQL2Parser.java:1357)
    at org.apache.jackrabbit.oak.query.SQL2Parser.parse(SQL2Parser.java:163)
    at org.apache.jackrabbit.oak.query.QueryEngineImpl.parseQuery(QueryEngineImpl.java:188)
    ... 31 more
{noformat}

> GQL queries with "jcr:primaryType='x'" don't use the node type index
> --------------------------------------------------------------------
>
>                 Key: OAK-1744
>                 URL: https://issues.apache.org/jira/browse/OAK-1744
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: query
>            Reporter: Thomas Mueller
>            Assignee: Thomas Mueller
>            Priority: Minor
>             Fix For: 1.3.15
>
>
> GQL queries (org.apache.jackrabbit.commons.query.GQL) with type restrictions are converted to the XPath condition "jcr:primaryType = 'x'". This conditions is not currently interpreted as a regular node type restriction in the query engine or the node type index, as one would expect. 
> Such restrictions could still be processed efficiently using the property index on "jcr:primaryType", but if that one is disabled (by setting the cost manually very high, as it is done now), then such queries don't use the expected index.
> I'm not sure yet where this should be best fixed.



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