I'm trying to count total rows of a fulltext search document. In Google documentation appear the expression count(size) however I do not get it to work.
I'm working in Java.
Is there any example about how to use 'count' expression?
Try this :
public void countRows() {
GetRequest request = GetRequest.newBuilder().setReturningIdsOnly(true)
.build();
int totalResult = (int) INDEX.getRange(request).getResults().size();
}
You have to declare :
private Index INDEX = SearchServiceFactory.getSearchService().getIndex(
IndexSpec.newBuilder().setName("your_doc_name"));
Note that : it's better if you don't count rows. For pagination, it should be next and previuos page link only. Sorry if my English is not good.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With