How to limit results from NXQL Query API REST

Hi, I don't know how I can LIMIT the number of results from a NXQL query. Any Idea? If the query returns me 200 results I want only 20 ,for example. Mi Nuxeo's version is 5.8 Can I do this? Thanks Regards

0 votes

4 answers

112 views

ANSWER



Hi, the following code works fine for me:

$client = new \Nuxeo\Automation\Client\NuxeoPhpAutomationClient('http://nuxeo:8080/nuxeo/site/automation');
$session = $client->getSession('Administrator', 'Administrator');
$docs = $session->newRequest('Document.Query')
  ->set('params', 'query', 'SELECT * FROM Document WHERE ecm:path STARTSWITH "/default-domain/workspaces/Default Workspace"')
  ->set('params', 'pageSize', 1)
  ->setSchema('*')
  ->sendRequest();

Can you share the NXQL query you use ?

1 votes



I have been looking at “Api Playground” and I can not find the way to limit the results, now I try to do it but there is no file in the repository and I do not know how to upload it. In the automation of php I introduce the parameters that should make the effect that I want in the query and it does not produce an error but it does not limit the results either

0 votes



$lo_answer = $lo_session->newRequest(“Document.Query”)

->set('params', 'query', $nxqlQuery)
->set('pageSize', 1)
->setSchema('*')
->sendRequest();

like that? not working …

I also tried to do:

$lo_answer = $lo_session->newRequest("Document.Query")
->set('params', 'query', $nxqlQuery)
->set('params','pageSize', 1)
->setSchema('*')
->sendRequest();

and does not…

0 votes



Example CURL request :

curl -X POST 'http://demo.nuxeo.com/nuxeo/site/automation/Repository.Query' -H 'X-Authentication-Token: a3c527bf-ed4b-4ff1-bb2a-e6e4625acc48' -H 'Nuxeo-Transaction-Timeout: 3' -H 'X-NXproperties: *' -H 'X-NXRepository: default' -H 'X-NXVoidOperation: false' -d '{"params":{"query":"select * from Document","currentPageIndex":"2","language":"NXQL","pageSize":"5","sortOrder":"ASC"},"context":{}}'

Try it there : http://nuxeo.github.io/api-playground

01/04/2017


Whether you use the REST API endpoint (/query/) or the automation operation (Repository.Query), you have a pageSize parameter (and currentPageIndex)

0 votes