Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When a sort control is used with a paging control, the result set is not sorted. #325

Open
trainKing-star opened this issue Feb 18, 2024 · 0 comments

Comments

@trainKing-star
Copy link

trainKing-star commented Feb 18, 2024

I used the UnboundID LDAP SDK to access the local OpenDJ server.

    <dependency>
      <groupId>com.unboundid</groupId>
      <artifactId>unboundid-ldapsdk</artifactId>
      <version>6.0.9</version>
    </dependency>

When only the sorting control is used, the sorting can be normally performed.

        final LDAPConnection connection = new LDAPConnection();
        connection.connect("127.0.0.1", 389, 1000);
        connection.bind("uid=test,cn=users,dc=example,dc=com", "test");
        SearchRequest searchRequest ;
        try {
            searchRequest = new SearchRequest("ou=page,ou=test,dc=example,dc=com", SearchScope.SUB, "uid=1*");
            searchRequest.addControl(new ServerSideSortRequestControl(new SortKey("uid", true)));
            SearchResult searchResult = connection.search(searchRequest);
            System.out.println("resultSize: " + searchResult.getEntryCount());
            for (SearchResultEntry searchEntry : searchResult.getSearchEntries()) {
                System.out.println(searchEntry);
            }
        } catch (LDAPException e) {
            throw new RuntimeException(e);
        }

The following result is returned:

resultSize: 1111
SearchResultEntry(dn='uid=1999,ou=page,ou=test
SearchResultEntry(dn='uid=1998,ou=page,ou=test
SearchResultEntry(dn='uid=1997,ou=page,ou=test
SearchResultEntry(dn='uid=1996,ou=page,ou=test
SearchResultEntry(dn='uid=1995,ou=page,ou=test
SearchResultEntry(dn='uid=1994,ou=page,ou=test
SearchResultEntry(dn='uid=1993,ou=page,ou=test
SearchResultEntry(dn='uid=1992,ou=page,ou=test
SearchResultEntry(dn='uid=1991,ou=page,ou=test
SearchResultEntry(dn='uid=1990,ou=page,ou=test
SearchResultEntry(dn='uid=199,ou=page,ou=test
SearchResultEntry(dn='uid=1989,ou=page,ou=test
SearchResultEntry(dn='uid=1988,ou=page,ou=test
SearchResultEntry(dn='uid=1987,ou=page,ou=test
SearchResultEntry(dn='uid=1986,ou=page,ou=test
SearchResultEntry(dn='uid=1985,ou=page,ou=test
SearchResultEntry(dn='uid=1984,ou=page,ou=test
SearchResultEntry(dn='uid=1983,ou=page,ou=test
SearchResultEntry(dn='uid=1982,ou=page,ou=test
SearchResultEntry(dn='uid=1981,ou=page,ou=test
··············································

When the sort control is used with the paging control, the sort is invalid.

        final LDAPConnection connection = new LDAPConnection();
        connection.connect("127.0.0.1", 389, 1000);
        connection.bind("uid=test,cn=users,dc=example,dc=com", "test");
        SearchRequest searchRequest ;
        try {
            searchRequest = new SearchRequest("ou=page,ou=test,dc=example,dc=com", SearchScope.SUB, "uid=1*");
            searchRequest.addControl(new ServerSideSortRequestControl(new SortKey("uid", true)));
            searchRequest.setControls(new SimplePagedResultsControl(10, null));
            SearchResult searchResult = connection.search(searchRequest);
            System.out.println("resultSize: " + searchResult.getEntryCount());
            for (SearchResultEntry searchEntry : searchResult.getSearchEntries()) {
                System.out.println(searchEntry);
            }
        } catch (LDAPException e) {
            throw new RuntimeException(e);
        }

The following result is returned:

resultSize: 10
SearchResultEntry(dn='uid=1,ou=page,ou=test
SearchResultEntry(dn='uid=10,ou=page,ou=test
SearchResultEntry(dn='uid=11,ou=page,ou=test
SearchResultEntry(dn='uid=12,ou=page,ou=test
SearchResultEntry(dn='uid=13,ou=page,ou=test
SearchResultEntry(dn='uid=14,ou=page,ou=test
SearchResultEntry(dn='uid=15,ou=page,ou=test
SearchResultEntry(dn='uid=16,ou=page,ou=test
SearchResultEntry(dn='uid=17,ou=page,ou=test
SearchResultEntry(dn='uid=18,ou=page,ou=test

Does OpenDj support paging after server-side sorting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant