manticoresearch-java icon indicating copy to clipboard operation
manticoresearch-java copied to clipboard

The default addition of "aggs": {} causes scroll pagination invalid

Open yeshimin opened this issue 3 months ago • 1 comments

sdk version: 8.1.0

    /**
     * search
     */
    public SearchResponse search(String tableName, String queryString, List<Object> sort, String scrollToken,
                                 Integer size) {
        ApiClient client = this.newClient();

        SearchQuery searchQuery = new SearchQuery();
        searchQuery.setQueryString(queryString);

        SearchRequest searchRequest = new SearchRequest();
        searchRequest.table(tableName).query(searchQuery);
        searchRequest.sort(sort);
        searchRequest.limit(size);

        // scroll pagination
        Map<String, Object> options = new HashMap<>();
        if (StrUtil.isNotBlank(scrollToken)) {
            options.put("scroll", scrollToken);
        } else {
            options.put("scroll", true);
        }
        searchRequest.options(options);

        SearchApi searchApi = new SearchApi(client);

        try {
            SearchResponse response = searchApi.search(searchRequest);
            log.debug("Search response: {}", response);
            return response;
        } catch (ApiException e) {
            this.printError(e);
            throw new RuntimeException(e);
        }
    }

final json body:

{
    "table": "products",
    "query": {
        "query_string": "黑色"
    },
    "join": [],
    "limit": 10,
    "aggs": {},
    "expressions": {},
    "options": {
        "scroll": "eyJvcmRlcl9ieV9zdHIiOiJzYWxlcyBhc2MsIGlkIGFzYyIsIm9yZGVyX2J5IjpbeyJhdHRyIjoic2FsZXMiLCJkZXNjIjpmYWxzZSwidmFsdWUiOjAsInR5cGUiOiJpbnQifSx7ImF0dHIiOiJpZCIsImRlc2MiOmZhbHNlLCJ2YWx1ZSI6MjMwOTE4NDQwMzM3NDM0MjE1MywidHlwZSI6ImludCJ9XX0="
    },
    "sort": [
        {
            "sales": {
                "order": "asc"
            }
        },
        {
            "id": {
                "order": "asc"
            }
        }
    ]
}

There is an "aggs": {}, is auto-generated, it will cause scroll pagination invalid. Did I use it incorrectly, or is this a feature or a bug ?

yeshimin avatar Aug 24 '25 14:08 yeshimin