Skip to main content
adobecq-venkat
Level 2
Nov 30, 2015 8:22 PM UTC
Solved

Xpath Search using Querymanager and getting totalmatch count

I am currently using xpath search for several reasons. However I didn't find TotalMatch Count on QueryResult class like SearchResult object using QueryBuilder.

            QueryManager qm=session.getWorkspace().getQueryManager();
            Query query = qm.createQuery(xpathQuery.toString(), Query.XPATH);

            query.setOffset(100);

            query.setLimit(25);
            QueryResult result = query.execute();

            NodeIterator iterator = result.getNodes();

 

I am searching for results on 4th page with a result limit of 25.

QueryResult class does not have any count method. I have to get NodeIterator or RowIterator to navigate to the result. These iterators will hold only number of rows set in setLimit method.

Can Someone help getting result count even after setting offset and limit on the query?

Thanks for your help!

Venkat

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
kautuk_sahni
kautuk_sahniAccepted solution
Level 9
Dec 1, 2015 6:15 AM UTC

Hi 

As far as i know, there is no function in QueryManager to do the same.

Only way to achieve it is by RowIterator.

Example:

RowIterator rowIterator = result.getRows();

while(rowIterator.hasNext()){

Row row = rowIterator.nextRow();

Value[] values = row.getValues();

}

I hope this would help you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni

2 replies

kautuk_sahni
kautuk_sahniAccepted solution
Level 9
Dec 1, 2015 6:15 AM UTC

Hi 

As far as i know, there is no function in QueryManager to do the same.

Only way to achieve it is by RowIterator.

Example:

RowIterator rowIterator = result.getRows();

while(rowIterator.hasNext()){

Row row = rowIterator.nextRow();

Value[] values = row.getValues();

}

I hope this would help you.

Thanks and Regards

Kautuk Sahni

Translate
Kautuk Sahni
adobecq-venkat
Level 2
Dec 1, 2015 5:07 PM UTC

Thanks Sahni for the answer!

Translate