Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

RangeIterator getSize() returns -1 for QueryResults getRows.getSize()

Avatar

Avatar
Validate 1
Level 1
shubhanshus3678
Level 1

Likes

0 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
shubhanshus3678
Level 1

Likes

0 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
shubhanshus3678
Level 1

26-03-2019

I am getting -1 on executing getSize() method on rowIterator and nodeIterator object from QueryResult getRows().

In doc it is suggested to use RangeIterator.getNumberRemaining  although no such method exists. I want to get the total number of rows returned by the query. Any inputs are helpful. RangeIterator (Content Repository for Java Technology API Version 2.0)

Replies

Avatar

Avatar
Validate 1
Level 7
Hemant_arora
Level 7

Likes

92 likes

Total Posts

290 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 50
View profile

Avatar
Validate 1
Level 7
Hemant_arora
Level 7

Likes

92 likes

Total Posts

290 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 50
View profile
Hemant_arora
Level 7

26-03-2019

I am able to get the number of rows using the below snippet:

// iterate over results

    QueryResult result = query.execute();

    NodeIterator nodes = result.getNodes();

    RangeIterator itr = result.getRows();

    logger.info("size==="+itr.getSize());

RangeIterator.getNumberRemaining seems to be a new change proposed in JCR2.0 API.

Proposed_JCR_2.0_API_Changes - Jackrabbit Wiki

Avatar

Avatar
Validate 1
Level 1
shubhanshus3678
Level 1

Likes

0 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
shubhanshus3678
Level 1

Likes

0 likes

Total Posts

4 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
shubhanshus3678
Level 1

26-03-2019

Tried same implementation, getSize() is returning -1 when rows returned are more than 100

Avatar

Avatar
Validate 1
Level 7
Hemant_arora
Level 7

Likes

92 likes

Total Posts

290 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 50
View profile

Avatar
Validate 1
Level 7
Hemant_arora
Level 7

Likes

92 likes

Total Posts

290 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 50
View profile
Hemant_arora
Level 7

26-03-2019

have u tried using query builder api instead ? using the search result object can help u get the correct number of rows.

Query query = queryBuilder.createQuery(PredicateGroup.create(map), session);

SearchResult result = query.getResult();

log.info("SIZE==="+result.getHits().size();)