You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by "jorgeeflorez ." <jo...@gmail.com> on 2019/09/08 20:09:25 UTC
Oak SQL-2 Query Grammar
Hello,
I have some questions about SQL-2, more specifically about the *union*
<https://jackrabbit.apache.org/oak/docs/query/grammar-sql2.html#query>
keyword (there is no example). I have two queries:
1) SELECT * FROM [nt:base] AS n WHERE (n.[jcr:primaryType] IN ('File',
'FolderL1', 'FolderL2', 'FolderL3', 'FolderL4', 'FolderL5')) AND
(lower(name(n)) like '%avion%' OR contains(n.*, 'avion'))
2) SELECT * FROM [nt:base] AS n WHERE (n.[jcr:primaryType] IN ('File',
'FolderL1', 'FolderL2', 'FolderL3', 'FolderL4', 'FolderL5')) AND
contains(n.[jcr:content/*], 'avion')
Number 1 returns three nodes, and number 2 returns two nodes (different
from the returned by number 1).
If I use UNION to connect both queries, should I get five nodes, right?
Right now I am getting three.
Can I use a different letter when I connect both queries using UNION? I
mean, I use in number 1 letter *n* and I want to use in number 2 letter *x*.
Something like this:
SELECT * FROM [nt:base] AS n WHERE (n.[jcr:primaryType] IN ('File',
'FolderL1', 'FolderL2', 'FolderL3', 'FolderL4', 'FolderL5')) AND
(lower(name(n)) like '%avion%' OR contains(n.*, 'avion')) UNION
SELECT * FROM [nt:base] AS x WHERE (x.[jcr:primaryType] IN ('File',
'FolderL1', 'FolderL2', 'FolderL3', 'FolderL4', 'FolderL5')) AND
contains(x.[jcr:content/*], 'avion')
I am not able to do that. I get (stacktrace was stripped):
javax.jcr.query.InvalidQueryException: java.text.ParseException: Unknown
selector: n
at
org.apache.jackrabbit.oak.jcr.query.QueryManagerImpl.executeQuery(QueryManagerImpl.java:148)
I don't know if that is ok.
Thanks in advance.
Jorge.