You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Santiago García Pimentel <sa...@netcentric.biz> on 2015/05/13 11:19:39 UTC
Is there a way to limit the results of a query using the Sling API?
Hello,
I wanted to use Sling to find some resources using SQL2 (I would prefer
not to use the JCR api directly). Unfortunately it seems that the use of
limit in the query is not supported, so it seems that my only option is
to create a JCR Query and use query.setLimit(int).
Is this correct? I would prefer to use only the Sling API to get these
resources. The ResourceResolver has a findResources() method, but it
does not accept any limit.
Greetings.
--
*Santiago García Pimentel* | Software Engineer
Netcentric Ibérica SL
Av. Diagonal 123 -8ª
08005 Barcelona
España
Skype: santiago.garciapimentel
santiago.pimentel@netcentric.biz | www.netcentric.es
Re: Is there a way to limit the results of a query using the Sling
API?
Posted by Carsten Ziegeler <cz...@apache.org>.
Am 15.05.15 um 11:52 schrieb Olaf:
> Hi Carsten
>
> I've actually developed something in this area already. It's basically prepared statements for XPATH and SQL queries, using the builder pattern. The solution is mature and in use in numerous large commercial deployments.
>
> Here is an example of what using it looks like for XPATH statements (quite the same for SQL)
>
> xpath("/jcr:root/content/?/?//*[@jcr:primaryType='cq:Page' and jcr:content/@sling:resourceType='?']")
> .setPath(0, "tenant")
> .setPath(1, "en")
> .set(2, "project/templates/articlePage")
> .execute(resourceResolver)
>
> So, there are placeholders with type-safe setters (most notably for paths, dates, calendars etc.), simple execution
> + a result that allows fast retrieval of resources, adaptation and pagination, with re-usable thread-safe iterators.
>
> If you are interested, I would offer to contribute it to what you are building.
>
Hi Olaf,
that's great - yes, any help is welcome. I'll publish my current stuff
next week and then we can start collaboration on it.
Regards
Carsten
--
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org
RE: Is there a way to limit the results of a query using the Sling API?
Posted by Olaf <ol...@x100.de>.
Hi Carsten
I've actually developed something in this area already. It's basically prepared statements for XPATH and SQL queries, using the builder pattern. The solution is mature and in use in numerous large commercial deployments.
Here is an example of what using it looks like for XPATH statements (quite the same for SQL)
xpath("/jcr:root/content/?/?//*[@jcr:primaryType='cq:Page' and jcr:content/@sling:resourceType='?']")
.setPath(0, "tenant")
.setPath(1, "en")
.set(2, "project/templates/articlePage")
.execute(resourceResolver)
So, there are placeholders with type-safe setters (most notably for paths, dates, calendars etc.), simple execution
+ a result that allows fast retrieval of resources, adaptation and pagination, with re-usable thread-safe iterators.
If you are interested, I would offer to contribute it to what you are building.
Regards,
Olaf
-----Original Message-----
From: Carsten Ziegeler [mailto:cziegeler@apache.org]
Sent: Mittwoch, 13. Mai 2015 15:24
To: users@sling.apache.org
Subject: Re: Is there a way to limit the results of a query using the Sling API?
I'm currently trying to design a new query API which is not string based anymore. It would be much easier to use, safer and in no way require you to write complex SQL or Xpath queries
I'll soon have a draft which I'll post here for discussion
Carsten
Am 13.05.15 um 11:55 schrieb Dirk Rudolph:
> There isn’t a way to do this so far but it would be a nice improvement.
>
> See https://issues.apache.org/jira/browse/SLING-1873
> <https://issues.apache.org/jira/browse/SLING-1873>
>
> Cheers, Dirk
> dirk.rudolph@netcentric.biz <ma...@netcentric.biz> |
> www.netcentric.biz <http://www.netcentric.biz/>
>> On 13 May 2015, at 11:19, Santiago García Pimentel <sa...@netcentric.biz> wrote:
>>
>> Hello,
>>
>> I wanted to use Sling to find some resources using SQL2 (I would prefer not to use the JCR api directly). Unfortunately it seems that the use of limit in the query is not supported, so it seems that my only option is to create a JCR Query and use query.setLimit(int).
>>
>> Is this correct? I would prefer to use only the Sling API to get these resources. The ResourceResolver has a findResources() method, but it does not accept any limit.
>>
>> Greetings.
>> --
>> *Santiago García Pimentel* | Software Engineer Netcentric Ibérica SL
>> Av. Diagonal 123 -8ª
>> 08005 Barcelona
>> España
>> Skype: santiago.garciapimentel
>> santiago.pimentel@netcentric.biz | www.netcentric.es
>
>
--
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org
Re: Is there a way to limit the results of a query using the Sling
API?
Posted by Alexander Klimetschek <ak...@adobe.com>.
Yet another query api/language?
Cheers,
Alex
> On 13.05.2015, at 06:23, Carsten Ziegeler <cz...@apache.org> wrote:
>
> I'm currently trying to design a new query API which is not string based
> anymore. It would be much easier to use, safer and in no way require you
> to write complex SQL or Xpath queries
>
> I'll soon have a draft which I'll post here for discussion
>
> Carsten
>
> Am 13.05.15 um 11:55 schrieb Dirk Rudolph:
>> There isn’t a way to do this so far but it would be a nice improvement.
>>
>> See https://issues.apache.org/jira/browse/SLING-1873 <https://issues.apache.org/jira/browse/SLING-1873>
>>
>> Cheers, Dirk
>> dirk.rudolph@netcentric.biz <ma...@netcentric.biz> | www.netcentric.biz <http://www.netcentric.biz/>
>>> On 13 May 2015, at 11:19, Santiago García Pimentel <sa...@netcentric.biz> wrote:
>>>
>>> Hello,
>>>
>>> I wanted to use Sling to find some resources using SQL2 (I would prefer not to use the JCR api directly). Unfortunately it seems that the use of limit in the query is not supported, so it seems that my only option is to create a JCR Query and use query.setLimit(int).
>>>
>>> Is this correct? I would prefer to use only the Sling API to get these resources. The ResourceResolver has a findResources() method, but it does not accept any limit.
>>>
>>> Greetings.
>>> --
>>> *Santiago García Pimentel* | Software Engineer
>>> Netcentric Ibérica SL
>>> Av. Diagonal 123 -8ª
>>> 08005 Barcelona
>>> España
>>> Skype: santiago.garciapimentel
>>> santiago.pimentel@netcentric.biz | www.netcentric.es
>>
>>
>
>
> --
> Carsten Ziegeler
> Adobe Research Switzerland
> cziegeler@apache.org
Re: Is there a way to limit the results of a query using the Sling
API?
Posted by Carsten Ziegeler <cz...@apache.org>.
I'm currently trying to design a new query API which is not string based
anymore. It would be much easier to use, safer and in no way require you
to write complex SQL or Xpath queries
I'll soon have a draft which I'll post here for discussion
Carsten
Am 13.05.15 um 11:55 schrieb Dirk Rudolph:
> There isn’t a way to do this so far but it would be a nice improvement.
>
> See https://issues.apache.org/jira/browse/SLING-1873 <https://issues.apache.org/jira/browse/SLING-1873>
>
> Cheers, Dirk
> dirk.rudolph@netcentric.biz <ma...@netcentric.biz> | www.netcentric.biz <http://www.netcentric.biz/>
>> On 13 May 2015, at 11:19, Santiago García Pimentel <sa...@netcentric.biz> wrote:
>>
>> Hello,
>>
>> I wanted to use Sling to find some resources using SQL2 (I would prefer not to use the JCR api directly). Unfortunately it seems that the use of limit in the query is not supported, so it seems that my only option is to create a JCR Query and use query.setLimit(int).
>>
>> Is this correct? I would prefer to use only the Sling API to get these resources. The ResourceResolver has a findResources() method, but it does not accept any limit.
>>
>> Greetings.
>> --
>> *Santiago García Pimentel* | Software Engineer
>> Netcentric Ibérica SL
>> Av. Diagonal 123 -8ª
>> 08005 Barcelona
>> España
>> Skype: santiago.garciapimentel
>> santiago.pimentel@netcentric.biz | www.netcentric.es
>
>
--
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org
Re: Is there a way to limit the results of a query using the Sling API?
Posted by Dirk Rudolph <di...@netcentric.biz>.
There isn’t a way to do this so far but it would be a nice improvement.
See https://issues.apache.org/jira/browse/SLING-1873 <https://issues.apache.org/jira/browse/SLING-1873>
Cheers, Dirk
dirk.rudolph@netcentric.biz <ma...@netcentric.biz> | www.netcentric.biz <http://www.netcentric.biz/>
> On 13 May 2015, at 11:19, Santiago García Pimentel <sa...@netcentric.biz> wrote:
>
> Hello,
>
> I wanted to use Sling to find some resources using SQL2 (I would prefer not to use the JCR api directly). Unfortunately it seems that the use of limit in the query is not supported, so it seems that my only option is to create a JCR Query and use query.setLimit(int).
>
> Is this correct? I would prefer to use only the Sling API to get these resources. The ResourceResolver has a findResources() method, but it does not accept any limit.
>
> Greetings.
> --
> *Santiago García Pimentel* | Software Engineer
> Netcentric Ibérica SL
> Av. Diagonal 123 -8ª
> 08005 Barcelona
> España
> Skype: santiago.garciapimentel
> santiago.pimentel@netcentric.biz | www.netcentric.es