Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

QueryBuilder's API, p.limit = vs p.limit = 1

Avatar

Level 7

When using com.day.cq.search.QueryBuilder, is there any difference between p.limit = 0 and p.limit = -1?

Seems to me that both behave the same, but in I could only find p.limit = -1 stated in the docs.

1 Accepted Solution

Avatar

Correct answer by
Level 6

LinearGradient wrote...

Thanks for the reply Ove. But what's the difference between  "unlimited with intention" "the default unlimited". smiley

And are they documented anywhere?

Thanks.

 


Hi,

it is more of a way of thinking when you create query languages. There might be limitations set by a connector or something that then honors the default limit notation (0) and if you want to intentionally get everything, regardless of any limitations, then you use the unlimited flag (-1).

I have myself done quite a lot of this kind of notations, so it is a common pattern to use -1 as "unlimited", 0 as "systems choise" and 0< for user selected limitations.

Havn't actually found any documentation on this so don't take my words as the absolute truth. Just falling back on "previous knowledge" ;)

 

/O

View solution in original post

3 Replies

Avatar

Level 6

The -1 is used for "unlimited with intention" and the 0 is "the default unlimited". If you use p.limit=<any positive integer>, that is the limit of the anwswers you get.

That is why only -1 is documented.

 

/Ove

Avatar

Level 7

Thanks for the reply Ove. But what's the difference between  "unlimited with intention" "the default unlimited". smiley

And are they documented anywhere?

Thanks.

Avatar

Correct answer by
Level 6

LinearGradient wrote...

Thanks for the reply Ove. But what's the difference between  "unlimited with intention" "the default unlimited". smiley

And are they documented anywhere?

Thanks.

 


Hi,

it is more of a way of thinking when you create query languages. There might be limitations set by a connector or something that then honors the default limit notation (0) and if you want to intentionally get everything, regardless of any limitations, then you use the unlimited flag (-1).

I have myself done quite a lot of this kind of notations, so it is a common pattern to use -1 as "unlimited", 0 as "systems choise" and 0< for user selected limitations.

Havn't actually found any documentation on this so don't take my words as the absolute truth. Just falling back on "previous knowledge" ;)

 

/O