0

I want to limit the number of result using JobSearchRestriction. I want to limit not by a condition, but by "hard coded" number. Somethig like "LIMIT 10".

Is it possible to do that in hybris using JobSearchRestriction?

Ricardo Machado
  • 784
  • 6
  • 22
  • use query.setCount(int) --> make variable configurable either in any model or in properties – Raushan Kumar Feb 24 '22 at 15:36
  • look here: https://stackoverflow.com/questions/51133420/how-to-limit-the-result-data-in-flexible-seach-query – Mafick Feb 27 '22 at 17:14
  • Does this answer your question? [How to limit the result data in flexible seach query](https://stackoverflow.com/questions/51133420/how-to-limit-the-result-data-in-flexible-seach-query) – Mafick Feb 27 '22 at 17:15
  • No, LIMIT 10 doesn't work on hana db, which I am using. And since it's a search restriction, it probably is appending on where query like and : "AND %searchRestrictionValue%", so I would not be able to use "AND LIMIT 10". Also, I don't have access to query.setCount because as I said, it's a search restriction, I only have controll over the value inside the query for search restriction. – Ricardo Machado Feb 28 '22 at 09:01

1 Answers1

0

Try this

SELECT * FROM {Product} LIMIT 10

or

SELECT TOP 10 * FROM {Product}

For Oracle

SELECT * FROM {Product} WHERE rownum <= 10

Though API

final FlexibleSearchQuery query = new FlexibleSearchQuery("SELECT * FROM {Product}");

query.setCount(10);
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103