Hi, what I mean is to create the query with your given String:
String query = "//element(*, nt:file) [jcr:like(@jcr:createdBy, 'u%')] order by @jcr:created descending"; Then with the resulting query object you can use as follows: query.setLimit(5); query.setOffset(10); BR Michael On Tue, 29 Jun 2010 10:50:08 +0200, Xiaojie Shen <[email protected]> wrote: > The result wasn't limited to 5 when I tried "//element(*, nt:file) > [jcr:like(@jcr:createdBy, 'u%')] order by @jcr:created descending limit 5". > limit(5) is bad request. Is limit() working only for sql search or shall I > use it in another way? > > BR > Shen > > -----Original Message----- > From: Michael Coldewey [mailto:[email protected]] > Sent: den 29 juni 2010 10:27 > To: [email protected] > Subject: Re: How to use position() in Xpath query > > > Hello, > > as I know, the position() function delivers only the order position in the > list of all childs of the parent node. So it is not > usefull to limit the results of a query. > > To limit the results in a query, you should use the "limit(int)" function > of the resulting query object. > > Greetings > Michael > > > > > On Tue, 29 Jun 2010 10:08:40 +0200, Xiaojie Shen > <[email protected]> wrote: >> Hi >> >> I saw an announce in 2007 that position() function doesn't work in > release >> 2.1. Is it the same today? >> >> If it works now, can somebody explain how to use position() in Xpath > query >> to limit the number of search results? For example, how should it be used >> to the query below? >> String query = "//element(*, nt:file) [jcr:like(@jcr:createdBy, 'u%')] >> order by @jcr:created descending"; >> >> Thanks in advance! >> Shen
