question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is sorting supported?

See original GitHub issue

I use PagingAndSortingRepository. And I try to get pageable parameter by request like this:

@GetMapping("/find")
public Page<Data> find(@PageableDefault(size = Integer.MAX_VALUE, sort = "timestamp") final Pageable pageable) {
	return dataRepository.findAll(pageable);
}

But when I try to use Page<Data> findAll(Pageable pageable) I catch UnsupportedOperationException: “Sorting not supported for find all scan operations”.

Is there any way to sort data? Thanks!

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:24 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
yoga-gupthacommented, Sep 14, 2018

I have a table with id

	@DynamoDBHashKey(attributeName = "id")
	@DynamoDBAutoGeneratedKey
	private String id;

And global secondary index with projection type ‘key only’

	@DynamoDBAttribute
	@DynamoDBIndexHashKey(globalSecondaryIndexName = TENANT_ID_INDEX_NAME)
	private String tenantId;

	@DynamoDBAttribute
	@DynamoDBTyped(DynamoDBMapperFieldModel.DynamoDBAttributeType.N)
	@DynamoDBTypeConverted(converter = DynamoDbInstantConverter.class)
	@DynamoDBIndexRangeKey(globalSecondaryIndexNames = TENANT_ID_INDEX_NAME)
	private Instant creationTimestamp;

Also I have repository method findByTenantIdOrderByCreationTimestampAsc(String tenantId, Pageable pageable); Search and sorting work well.

Now I need have folow method findByTenantIdAndExpirationDateGreaterThanOrderByCreationTimestampAsc(String tenantId, long expirationDate, Pageable pageable)

I tried to create second global secondary index by expirationDate and creationTimestamp. But I caught an exception: java.lang.UnsupportedOperationException: Sort not supported for scan expressions

I tried modify first global secondary index. I setted projection type as ‘include’ and set expirationDate as non key attribut. But I caught the same exception.

How can I implement needed behavior?

Many thanks for considering my request!

Hi May I know how did you fix this scenario, I have the same case Can you provide your approach It would helpful to me a lot Thanks.

1reaction
gauravbrillscommented, Feb 2, 2018

Ya I also observed the use of @EnableScan @EnableScanCount Page<contact> findAll(Pageable pageable); fails now which used to work in older version . Is it cause now the default sort enum is coming as UNSORTED …

this leads to the exception for the sorting check

“Sorting not supported for find all scan operations”

I guess we should put a UNSORTED check here or something likewise .

`@Override public Page<T> findAll(Pageable pageable) {

	if (pageable.getSort() != null) {
		throw new UnsupportedOperationException("Sorting not supported for find all scan operations");
	}`
Read more comments on GitHub >

github_iconTop Results From Across the Web

When to use each Sorting Algorithm - GeeksforGeeks
Merge sort is used when the data structure doesn't support random access since it works with pure sequential access that is forward iterators, ......
Read more >
SORT function - Microsoft Support
The SORT function is provided to sort data in an array. If you want to sort data in the grid, it's better to...
Read more >
How to Use sorted() and sort() in Python - Real Python
All programmers will have to write code to sort items or data at some point. Sorting can be critical to the user experience...
Read more >
not supported between instances of" when sorting two lists ...
The credit of this answer goes to @jasonharper. He said in a comment: If two of your floats are equal, Python is going...
Read more >
std::sort - cppreference.com
A sequence is sorted with respect to a comparator comp if for any iterator it pointing to the sequence and any non-negative integer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found