0
votes

I have the below working query

path=/content/dam
type=sling:OrderedFolder
nodename=[0-9][0-9][0-9][0-9]-([0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9])
property=jcr:content/metadataprofile
property.operation=exists
property.value=false
p.limit=-1

It runs on entire Path=/content/dam, so it traverse all nodes for about 20 minutes and gives results.

How can i make it in batches when using query-builder api programatically, like - traverse 1000 nodes and do-something code-wise and then continue with query and traversing next 1000 nodes and so-on ? Is it possible ?
Thanks in advance.

1
@cylinder.y could you provide any link for pagination sample code ?Tarun Prakash
you may look into my old answer here ^ stackoverflow.com/questions/51505913/…cylinder.y

1 Answers

0
votes

You may use pagination approach from here: https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/querybuilder-api.html#ExampleQueryBuilderAPIUsage

Pagination is configured in the following way:

// can be done in map or with Query methods
map.put("p.offset", "0"); // same as query.setStart(0) below
map.put("p.limit", "20"); // same as query.setHitsPerPage(20) below

or

query.setStart(0);
query.setHitsPerPage(20);

and go throught result in a loop:

// iterating over the results
for (Hit hit : result.getHits()) {
    String path = hit.getPath();
    ......
}

For more details, please has a look into Implementing pagination on the page provided above.