Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Total count in Google appengine fulltext search

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?

like image 283
Mario Nubbius Avatar asked Nov 04 '22 10:11

Mario Nubbius


1 Answers

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.

like image 105
xuanhung2401 Avatar answered Nov 10 '22 03:11

xuanhung2401