Search question, with jcr:path.

View: New views
2 Messages — Rating Filter:   Alert me  

Search question, with jcr:path.

by hsp_ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi;
I have a need to search node in a level that not match some names.
Take the following tree:

A
A/B
A/B/D
A/C
A/C/E


So, I want to retrieve the nodes only under A, that have the names (or path) not equal to B (node A/C would be the result in this case).

I tried some searches with xpath and sql, but without sucess.

Well, in the url http://people.apache.org/~mreutegg/jcr-query-translator/translator.html, I post the following xpath:
/jcr:root/A/element(*,my:type)[(@jcr:path!='/A/B')]

and in SQL Query box appears:
SELECT * FROM my:type WHERE jcr:path <> '/A/B' AND jcr:path LIKE '/A[%]/%' AND NOT jcr:path LIKE '/A[%]/%/%'

and in JCR Query tree box appears:
+ Root node
+ Select properties: *
  + PathQueryNode
    + LocationStepQueryNode:  NodeTest={} Descendants=false Index=NONE
    + LocationStepQueryNode:  NodeTest={}A Descendants=false Index=NONE
    + LocationStepQueryNode:  NodeTest=* Descendants=false Index=NONE
      + NodeTypeQueryNode:  Prop={http://www.jcp.org/jcr/1.0}primaryType Value={my}type
      + RelationQueryNode: Op: <> Prop=@{http://www.jcp.org/jcr/1.0}path Type=STRING Value=/A/B

I did the search in jackrabbit with xpath and nor result nor exception returned.
I did the search in jackrabbit with sql and get the exception:
"javax.jcr.query.InvalidQueryException: Invalid combination of jcr:path clauses"

How can I do the filter in query to get directly the nodes without handle after in my code?
I also tried using fn:name but it only works with "=" predicates.

Thanks
Helio.

Re: Search question, with jcr:path.

by Marcel Reutegger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

hsp_ wrote:

> Hi;
> I have a need to search node in a level that not match some names.
> Take the following tree:
>
> A
> A/B
> A/B/D
> A/C
> A/C/E
>
>
> So, I want to retrieve the nodes only under A, that have the names (or path)
> not equal to B (node A/C would be the result in this case).
>
> I tried some searches with xpath and sql, but without sucess.
>
> Well, in the url
> http://people.apache.org/~mreutegg/jcr-query-translator/translator.html, I
> post the following xpath:
> /jcr:root/A/element(*,my:type)[(@jcr:path!='/A/B')]

jcr:path is a pseudo property that you can only use with SQL.

> and in SQL Query box appears:
> SELECT * FROM my:type WHERE jcr:path <> '/A/B' AND jcr:path LIKE '/A[%]/%'
> AND NOT jcr:path LIKE '/A[%]/%/%'
>
> and in JCR Query tree box appears:
> + Root node
> + Select properties: *
>   + PathQueryNode
>     + LocationStepQueryNode:  NodeTest={} Descendants=false Index=NONE
>     + LocationStepQueryNode:  NodeTest={}Documentador Descendants=false
> Index=NONE
>     + LocationStepQueryNode:  NodeTest={}Acervo Descendants=false Index=NONE
>     + LocationStepQueryNode:  NodeTest=* Descendants=false Index=NONE
>       + NodeTypeQueryNode:  Prop={http://www.jcp.org/jcr/1.0}primaryType
> Value={my}type
>       + RelationQueryNode: Op: <> Prop=@{http://www.jcp.org/jcr/1.0}path
> Type=STRING Value=/A/B
>
> I did the search in jackrabbit with xpath and nor result nor exception
> returned.

that's because there is no property called jcr:path.

> I did the search in jackrabbit with sql and get the exception:
> "javax.jcr.query.InvalidQueryException: Invalid combination of jcr:path
> clauses"

SQL only supports a certain combinations of jcr:path matches. see the jsr 170
specification for details.

> How can I do the filter in query to get directly the nodes without handle
> after in my code?
> I also tried using fn:name but it only works with "=" predicates.

the equals operator is currently the only one supported with fn:name. please
file an enhancement request for other operators that you would like to have
implemented. thanks.

regards
  marcel