1

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?

RLH
  • 15,230
  • 22
  • 98
  • 182
Anders
  • 71
  • 5
  • Try setting the default sort value to 0 (numeric) instead of "0" (string) -- does that fix it? – Amy U. May 13 '12 at 23:53
  • Edit to the above-- you will need to use `setDefaultValueNumeric(0)` to set the default instead. In my tests, this works for me. – Amy U. May 14 '12 at 07:10
  • Still the same problem. Good to know about setDefaultValueNumeric(), I had missed that but the problem remains. I'm running only on the developer server and I have deleted all content under directory appengine-generated several times which may have messed things up, I don't know. Will test it on the production server later on. – Anders May 14 '12 at 07:40

0 Answers0