[jira] [Commented] (OAK-6792) rep:facet not supported in xpath

2017-11-04 Thread Vikas Saurabh (JIRA)

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

Vikas Saurabh commented on OAK-6792:


Backported to 1.4 at [r1814334|https://svn.apache.org/r1814334].

> rep:facet not supported in xpath
> 
>
> Key: OAK-6792
> URL: https://issues.apache.org/jira/browse/OAK-6792
> Project: Jackrabbit Oak
>  Issue Type: Improvement
>  Components: query
>Reporter: Vikas Saurabh
>Assignee: Vikas Saurabh
>  Labels: candidate_oak_1_4
> Fix For: 1.8, 1.4.19, 1.7.10, 1.6.7
>
>
> Parsing
> {noformat}
> //element(*, app:Asset)/(rep:facet(jcr:createdBy))
> {noformat}
> gives following exception.
> {noformat}
> Caused by: java.text.ParseException: Query:
> /jcr_root//element(*, app:Asset)/rep:facet(jcr:createdBy(*))
> {noformat}
> /cc [~tmueller]



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (OAK-6792) rep:facet not supported in xpath

2017-11-04 Thread Vikas Saurabh (JIRA)

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

Vikas Saurabh commented on OAK-6792:


Updated fix on trunk at [r1814332|https://svn.apache.org/r1814332].

> rep:facet not supported in xpath
> 
>
> Key: OAK-6792
> URL: https://issues.apache.org/jira/browse/OAK-6792
> Project: Jackrabbit Oak
>  Issue Type: Improvement
>  Components: query
>Reporter: Vikas Saurabh
>Assignee: Vikas Saurabh
>  Labels: candidate_oak_1_4
> Fix For: 1.8, 1.7.10, 1.6.7
>
>
> Parsing
> {noformat}
> //element(*, app:Asset)/(rep:facet(jcr:createdBy))
> {noformat}
> gives following exception.
> {noformat}
> Caused by: java.text.ParseException: Query:
> /jcr_root//element(*, app:Asset)/rep:facet(jcr:createdBy(*))
> {noformat}
> /cc [~tmueller]



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (OAK-6792) rep:facet not supported in xpath

2017-11-04 Thread Vikas Saurabh (JIRA)

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

Vikas Saurabh commented on OAK-6792:


Talked to [~tmueller] offline, and the patch above (which works on 1.4) is 
preferable. I would hence apply it on trunk and on 1.6 too (i.e. undo the 
previous change and put this one in).

> rep:facet not supported in xpath
> 
>
> Key: OAK-6792
> URL: https://issues.apache.org/jira/browse/OAK-6792
> Project: Jackrabbit Oak
>  Issue Type: Improvement
>  Components: query
>Reporter: Vikas Saurabh
>Assignee: Vikas Saurabh
>  Labels: candidate_oak_1_4
> Fix For: 1.8, 1.7.10, 1.6.7
>
>
> Parsing
> {noformat}
> //element(*, app:Asset)/(rep:facet(jcr:createdBy))
> {noformat}
> gives following exception.
> {noformat}
> Caused by: java.text.ParseException: Query:
> /jcr_root//element(*, app:Asset)/rep:facet(jcr:createdBy(*))
> {noformat}
> /cc [~tmueller]



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (OAK-6792) rep:facet not supported in xpath

2017-11-02 Thread Vikas Saurabh (JIRA)

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

Vikas Saurabh commented on OAK-6792:


[~tmueller], backporting to 1.4 didn't work out for me. What instead did work 
was:
{noformat}
Index: 
oak-core/src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java
===
--- 
oak-core/src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java
  (revision 1814026)
+++ 
oak-core/src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java
  (working copy)
@@ -247,6 +247,21 @@
 readOpenDotClose(true);
 Expression.Property p = new 
Expression.Property(currentSelector, "rep:suggest()", false);
 statement.addSelectColumn(p);
+} else if (readIf("rep:facet")) {
+// this will also deal with relative properties
+// (functions and so on are also working, but this is 
probably not needed)
+read("(");
+Expression e = parseExpression();
+if (!(e instanceof Expression.Property)) {
+throw getSyntaxError();
+}
+Expression.Property prop = (Expression.Property) e;
+String property = prop.getColumnAliasName();
+read(")");
+rewindSelector();
+Expression.Property p = new 
Expression.Property(currentSelector,
+"rep:facet(" + property + ")", false);
+statement.addSelectColumn(p);
 }
 } while (readIf("|"));
 read(")");
{noformat}
It's essentially the same way we are parsing the expression - just at a 
different place. Would this be preferable? If so, should I do this on trunk and 
1.6 too?

> rep:facet not supported in xpath
> 
>
> Key: OAK-6792
> URL: https://issues.apache.org/jira/browse/OAK-6792
> Project: Jackrabbit Oak
>  Issue Type: Improvement
>  Components: query
>Reporter: Vikas Saurabh
>Assignee: Vikas Saurabh
>Priority: Major
>  Labels: candidate_oak_1_4
> Fix For: 1.8, 1.7.10, 1.6.7
>
>
> Parsing
> {noformat}
> //element(*, app:Asset)/(rep:facet(jcr:createdBy))
> {noformat}
> gives following exception.
> {noformat}
> Caused by: java.text.ParseException: Query:
> /jcr_root//element(*, app:Asset)/rep:facet(jcr:createdBy(*))
> {noformat}
> /cc [~tmueller]



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (OAK-6792) rep:facet not supported in xpath

2017-11-02 Thread Vikas Saurabh (JIRA)

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

Vikas Saurabh commented on OAK-6792:


Backported to 1.6 at [r1814034|https://svn.apache.org/r1814034

> rep:facet not supported in xpath
> 
>
> Key: OAK-6792
> URL: https://issues.apache.org/jira/browse/OAK-6792
> Project: Jackrabbit Oak
>  Issue Type: Improvement
>  Components: query
>Reporter: Vikas Saurabh
>Assignee: Vikas Saurabh
>Priority: Major
>  Labels: candidate_oak_1_4
> Fix For: 1.8, 1.7.10, 1.6.7
>
>
> Parsing
> {noformat}
> //element(*, app:Asset)/(rep:facet(jcr:createdBy))
> {noformat}
> gives following exception.
> {noformat}
> Caused by: java.text.ParseException: Query:
> /jcr_root//element(*, app:Asset)/rep:facet(jcr:createdBy(*))
> {noformat}
> /cc [~tmueller]



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (OAK-6792) rep:facet not supported in xpath

2017-10-12 Thread Thomas Mueller (JIRA)

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

Thomas Mueller commented on OAK-6792:
-

New patch to support relative properties:

{noformat}
### Eclipse Workspace Patch 1.0
#P oak-core
Index: src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
===
--- src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
(revision 1811333)
+++ src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
(working copy)
@@ -24,6 +24,21 @@
 # * new tests are typically be added on top, after the syntax docs
 # * use ascii character only
 
+# OAK-6792
+
+xpath2sql /jcr:root//*/(rep:facet(jcr:data/jcr:createdBy))
+select [jcr:path], [jcr:score], [rep:facet(jcr:data/jcr:createdBy)]
+  from [nt:base] as a
+  where isdescendantnode(a, '/')
+  /* xpath ... */
+
+
+xpath2sql /jcr:root//*/(rep:facet(jcr:createdBy))
+select [jcr:path], [jcr:score], [rep:facet(jcr:createdBy)]
+  from [nt:base] as a
+  where isdescendantnode(a, '/')
+  /* xpath ... */
+
 # OAK-6778
 
 xpath2sql explain /jcr:root/content/(activities|people)//element(*, acme:Asset)
@@ -31,7 +46,7 @@
   from [acme:Asset] as a
   where isdescendantnode(a, '/content/activities')
   /* xpath ... */
-  
+ 
 xpath2sql explain measure /jcr:root/content/(activities|people)//element(*, 
acme:Asset)
 explain measure select [jcr:path], [jcr:score], *
   from [acme:Asset] as a
Index: 
src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java
===
--- 
src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java   
(revision 1811333)
+++ 
src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java   
(working copy)
@@ -234,6 +234,20 @@
 rewindSelector();
 Expression.Property p = new 
Expression.Property(currentSelector, "rep:excerpt", false);
 statement.addSelectColumn(p);
+} else if ("rep:facet".equals(identifier)) {
+// this will also deal with relative properties
+// (functions and so on are also working, but this is 
probably not needed)
+Expression e = parseExpression();
+if (!(e instanceof Expression.Property)) {
+throw getSyntaxError();
+}
+Expression.Property prop = (Expression.Property) e;
+String property = prop.getColumnAliasName();
+read(")");
+rewindSelector();
+Expression.Property p = new 
Expression.Property(currentSelector, 
+"rep:facet(" + property + ")", false);
+statement.addSelectColumn(p);
 } else {
 throw getSyntaxError();
 }

{noformat}

> rep:facet not supported in xpath
> 
>
> Key: OAK-6792
> URL: https://issues.apache.org/jira/browse/OAK-6792
> Project: Jackrabbit Oak
>  Issue Type: Improvement
>  Components: query
>Reporter: Vikas Saurabh
>
> Parsing
> {noformat}
> //element(*, app:Asset)/(rep:facet(jcr:createdBy))
> {noformat}
> gives following exception.
> {noformat}
> Caused by: java.text.ParseException: Query:
> /jcr_root//element(*, app:Asset)/rep:facet(jcr:createdBy(*))
> {noformat}
> /cc [~tmueller]



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (OAK-6792) rep:facet not supported in xpath

2017-10-12 Thread Thomas Mueller (JIRA)

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

Thomas Mueller commented on OAK-6792:
-

Proposed patch (just tests the conversion; more tests are needed):

{noformat}
### Eclipse Workspace Patch 1.0
#P oak-core
Index: src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
===
--- src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
(revision 1811333)
+++ src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
(working copy)
@@ -24,6 +24,14 @@
 # * new tests are typically be added on top, after the syntax docs
 # * use ascii character only
 
+# OAK-6792
+
+xpath2sql /jcr:root//*/(rep:facet(jcr:createdBy))
+select [jcr:path], [jcr:score], [rep:facet(jcr:createdBy)]
+  from [nt:base] as a
+  where isdescendantnode(a, '/')
+  /* xpath ... */
+
 # OAK-6778
 
 xpath2sql explain /jcr:root/content/(activities|people)//element(*, acme:Asset)
@@ -31,7 +39,7 @@
   from [acme:Asset] as a
   where isdescendantnode(a, '/content/activities')
   /* xpath ... */
-  
+ 
 xpath2sql explain measure /jcr:root/content/(activities|people)//element(*, 
acme:Asset)
 explain measure select [jcr:path], [jcr:score], *
   from [acme:Asset] as a
Index: 
src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java
===
--- 
src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java   
(revision 1811333)
+++ 
src/main/java/org/apache/jackrabbit/oak/query/xpath/XPathToSQL2Converter.java   
(working copy)
@@ -234,6 +234,13 @@
 rewindSelector();
 Expression.Property p = new 
Expression.Property(currentSelector, "rep:excerpt", false);
 statement.addSelectColumn(p);
+} else if ("rep:facet".equals(identifier)) {
+String property = readIdentifier();
+read(")");
+rewindSelector();
+Expression.Property p = new 
Expression.Property(currentSelector, 
+"rep:facet(" + property + ")", false);
+statement.addSelectColumn(p);
 } else {
 throw getSyntaxError();
 }
{noformat}

> rep:facet not supported in xpath
> 
>
> Key: OAK-6792
> URL: https://issues.apache.org/jira/browse/OAK-6792
> Project: Jackrabbit Oak
>  Issue Type: Improvement
>  Components: query
>Reporter: Vikas Saurabh
>
> Parsing
> {noformat}
> //element(*, app:Asset)/(rep:facet(jcr:createdBy))
> {noformat}
> gives following exception.
> {noformat}
> Caused by: java.text.ParseException: Query:
> /jcr_root//element(*, app:Asset)/rep:facet(jcr:createdBy(*))
> {noformat}
> /cc [~tmueller]



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (OAK-6792) rep:facet not supported in xpath

2017-10-06 Thread Vikas Saurabh (JIRA)

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

Vikas Saurabh commented on OAK-6792:


Oh... yes, you're right... I wanted that to be a column in result row... not a 
condition. (so, yes I wanted {{/jcr_root//element(*, 
app:Asset)/(rep:facet(jcr:createdBy))}}. Let me run the query again in a bit - 
I'd update the description accordingly.

> rep:facet not supported in xpath
> 
>
> Key: OAK-6792
> URL: https://issues.apache.org/jira/browse/OAK-6792
> Project: Jackrabbit Oak
>  Issue Type: Improvement
>  Components: query
>Reporter: Vikas Saurabh
>
> Parsing
> {noformat}
> //element(*, app:Asset)[rep:facet(jcr:createdBy)]
> {noformat}
> gives following exception.
> {noformat}
> javax.jcr.query.InvalidQueryException: java.text.ParseException: Query:
> //element(*, app:Asset)[rep:facet(jcr:createdBy(*))]; expected: jcr:like | 
> jcr:contains | jcr:score | xs:dateTime | fn:lower-case | fn:upper-case | 
> fn:name | rep:similar | rep:spellcheck | rep:suggest
> {noformat}
> /cc [~tmueller]



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Commented] (OAK-6792) rep:facet not supported in xpath

2017-10-06 Thread Thomas Mueller (JIRA)

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

Thomas Mueller commented on OAK-6792:
-

Yes, currently it looks like this only works with SQL-2, according to the docs 
at http://jackrabbit.apache.org/oak/docs/query/query-engine.html#Facets

But I think the syntax would need to be slightly different, as the above would 
be converted to "where [rep:facet(jcr:createdBy)] is not null". You probably 
(?) want something like this (see xpath syntax for 
[suggestions|http://jackrabbit.apache.org/oak/docs/query/query-engine.html#Suggestions]):

{noformat}
/jcr:root//*/(rep:facet(jcr:createdBy))
{noformat}

> rep:facet not supported in xpath
> 
>
> Key: OAK-6792
> URL: https://issues.apache.org/jira/browse/OAK-6792
> Project: Jackrabbit Oak
>  Issue Type: Improvement
>  Components: query
>Reporter: Vikas Saurabh
>
> Parsing
> {noformat}
> //element(*, app:Asset)[rep:facet(jcr:createdBy)]
> {noformat}
> gives following exception.
> {noformat}
> javax.jcr.query.InvalidQueryException: java.text.ParseException: Query:
> //element(*, app:Asset)[rep:facet(jcr:createdBy(*))]; expected: jcr:like | 
> jcr:contains | jcr:score | xs:dateTime | fn:lower-case | fn:upper-case | 
> fn:name | rep:similar | rep:spellcheck | rep:suggest
> {noformat}
> /cc [~tmueller]



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)