You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by sam web scale expert <sk...@gmail.com> on 2011/07/14 01:07:35 UTC

storing query in resource?

Is there query api that builds query from resources?
Since a resource is a tree, I was thinking I could express query as a
resource (a tree):

GET /query/foo.json

will return the query result of foo as json. The query is structured in
/query/foo  tree.

/query/foo/@searchRoot = "/content/diaries"
/query/foo/or/has/@bar = True
/query/foo/or/has/@author = True
/query/foo/or/and/is/@publishDate = 2011-07-03 00:00:00
/query/foo/or/and/is/@cateogry = "secret"
...
would build:
/jcr:root/content/diaries//*[(@bar and @author) or (@publishDate =
'2011-07-03 00:00:00' and @category = 'secret')]


Is there something like this?
If not, would having this kind of API be useful?
I know I can just store xpath as a property in a node... But since xpath is
deprecated in JCR 2.0, I was wondering if it could be useful to store query
in a resource somehow.

It's like prepared queries.. in a way.
And the resource might even cache query results and run the query only when
needed to.

Re: storing query in resource?

Posted by Mark Adamcin <ad...@gmail.com>.
Hi Sam,

JCR 2.0 supports storing queries as nodes, but not any of the fancy features
you are asking for.

Here is the appropriate section in the spec:

http://www.day.com/specs/jcr/2.0/6_Query.html#6.9.7%20Stored%20Query

Mark Adamcin
Acquity Group



On Wed, Jul 13, 2011 at 4:07 PM, sam web scale expert <sk...@gmail.com>wrote:

> Is there query api that builds query from resources?
> Since a resource is a tree, I was thinking I could express query as a
> resource (a tree):
>
> GET /query/foo.json
>
> will return the query result of foo as json. The query is structured in
> /query/foo  tree.
>
> /query/foo/@searchRoot = "/content/diaries"
> /query/foo/or/has/@bar = True
> /query/foo/or/has/@author = True
> /query/foo/or/and/is/@publishDate = 2011-07-03 00:00:00
> /query/foo/or/and/is/@cateogry = "secret"
> ...
> would build:
> /jcr:root/content/diaries//*[(@bar and @author) or (@publishDate =
> '2011-07-03 00:00:00' and @category = 'secret')]
>
>
> Is there something like this?
> If not, would having this kind of API be useful?
> I know I can just store xpath as a property in a node... But since xpath is
> deprecated in JCR 2.0, I was wondering if it could be useful to store query
> in a resource somehow.
>
> It's like prepared queries.. in a way.
> And the resource might even cache query results and run the query only when
> needed to.
>

Re: storing query in resource?

Posted by Justin Edelson <ju...@justinedelson.com>.
This is definitely an interesting idea, but you'd need some kind of
tooling. Otherwise, it's just easier to write the XPATH query by hand
IMHO.

On Wed, Jul 13, 2011 at 7:07 PM, sam web scale expert <sk...@gmail.com> wrote:
> Is there query api that builds query from resources?
> Since a resource is a tree, I was thinking I could express query as a
> resource (a tree):
>
> GET /query/foo.json
>
> will return the query result of foo as json. The query is structured in
> /query/foo  tree.
>
> /query/foo/@searchRoot = "/content/diaries"
> /query/foo/or/has/@bar = True
> /query/foo/or/has/@author = True
> /query/foo/or/and/is/@publishDate = 2011-07-03 00:00:00
> /query/foo/or/and/is/@cateogry = "secret"
> ...
> would build:
> /jcr:root/content/diaries//*[(@bar and @author) or (@publishDate =
> '2011-07-03 00:00:00' and @category = 'secret')]
>
>
> Is there something like this?
> If not, would having this kind of API be useful?
> I know I can just store xpath as a property in a node... But since xpath is
> deprecated in JCR 2.0, I was wondering if it could be useful to store query
> in a resource somehow.
>
> It's like prepared queries.. in a way.
> And the resource might even cache query results and run the query only when
> needed to.
>