Skip to main content
LinearGradient
Level 6
Oct 16, 2015 2:28 AM UTC
Solved

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

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Ove_LindströmAccepted solution
Level 6
Oct 16, 2015 2:28 AM UTC

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

3 replies

Ove_LindströmAccepted solution
Level 6
Oct 16, 2015 2:28 AM UTC

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

Translate
LinearGradient
Level 6
Oct 16, 2015 2:28 AM UTC

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

And are they documented anywhere?

Thanks.

Translate
Level 6
Oct 16, 2015 2:28 AM UTC

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

Translate