Limit in Search API not working?

573 Views Asked by At

I added 11 documents with a numeric field set to 1 to 11. And set sorting on the numeric field.

    SortOptions sortOptions = SortOptions.newBuilder()
            .addSortExpression(SortExpression.newBuilder()
                    .setExpression(NUMERIC_FIELD)
                    .setDirection(SortExpression.SortDirection.DESCENDING)
                    .setDefaultValue("0"))
            .setLimit(1000)
            .build();
    QueryOptions options = QueryOptions.newBuilder()
            .setLimit(maxResults)                       
            .setSortOptions(sortOptions)
            .setCursor(cursor)
            .build();
    Query query = Query.newBuilder().setOptions(options).build(queryString);

When maxResults is set to 11 or higher it works fine, but for lower values the results returned are ordered incorrectly. Before I post this as a bug, have I made a mistake somewhere?

0

There are 0 best solutions below