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

Method Skip is not supported while querying Cosmos DB #377

Closed
melzoghbi opened this issue Nov 2, 2017 · 18 comments
Closed

Method Skip is not supported while querying Cosmos DB #377

melzoghbi opened this issue Nov 2, 2017 · 18 comments

Comments

@melzoghbi
Copy link

Hi,

While i am trying to implement pagination in the cosmos db query. i am getting this error:

Microsoft.Azure.Documents.Client: Method 'Skip' is not supported.

Here is my C# code:

IDocumentQuery<T> query = client.CreateDocumentQuery<T>(
                UriFactory.CreateDocumentCollectionUri(DatabaseId, CollectionId),
                new FeedOptions { MaxItemCount = -1 })
                .Where(predicate)
                .Skip(pageIndex)
                .Take(pageSize) 
                .AsDocumentQuery();

How would i fix this? Thanks.

@kirankumarkolli
Copy link
Member

@bchong95 can you please take a look?

@bchong95
Copy link

bchong95 commented Nov 7, 2017

Hi,

We currently do not support Skip in SQL queries (and thus we don't support it for LINQ).

The workaround is to leverage the Continuation Token retrieved from executing the query.

This blog post talks about how this can be achieved:

http://www.kevinkuszyk.com/2016/08/19/paging-through-query-results-in-azure-documentdb/

Note that this method still consumes RUs to get to the skip point that you are interested in, so the recommendation is to keep these continuation tokens around for as long as possible. This means that if you have a webpage of paginated results, then you can periodically drain the query from start to finish and save the continuation tokens generated to have skip points.

In the future we will support client side skips.

Thank you,

@melzoghbi
Copy link
Author

Thanks @bchong95. I am checking this solution out and will get back to you.

@melzoghbi
Copy link
Author

This works. Thanks a lot @bchong95 :-) you can close this issue.

@pwen090
Copy link

pwen090 commented May 5, 2018

I have seen on UserVoice that adding Skip and Take are being worked on but I cannot seem to find the github issue for that feature, is there one? thank you

@garfbradaz
Copy link

Starting my pagination journey for CosmosDB today, this does seem alittle painful not having skip.

@ghost
Copy link

ghost commented Jun 13, 2018

Take is already present, you can limit the number or items to get.
As for Skip, first we were upset that there is no Skip, but later we realized that Skip would consume significant amount of RUs and such solution would not work in general case if you have thousands or millions documents.

So we allow pagination only by continuation token, e.g. virtual scroll etc. If you want to jump to page number 1000 - just use more specific query, like date time etc.

@georgiosd
Copy link

georgiosd commented Jun 16, 2018

This is a serious shortcoming. Integrating with Material UI pagination seems too hard to be worth it.

I have to say, DocumentDB is missing a lot of features that I've taken for granted in RavenDB. Not affiliated with them, just a fan since RavenDB 2.0.

@rmja
Copy link

rmja commented Jun 20, 2018

Here is the UserVoise issue for missing Skip This is really something I expected would be baked in by now.

@garfbradaz
Copy link

Ive done paging fine without Skip.

@wilkovanderveen
Copy link

      Ive done paging fine without Skip.

Please enlighten us.

@rmarskell
Copy link

@melzoghbi Can you please reopen this? The issue as stated has not been resolved and I didn't see any open issues this is a duplicate of. Based on the user voice link above, it's being worked on so it would be nice to be able to track it here.

@felipecruz91
Copy link

Any news on this?

@thiagospassos
Copy link

Wow, I'm really surprised this is not yet available. Any plans to work on this feature at all?

@vip32
Copy link

vip32 commented May 13, 2019

offset/limit (skip/take) is now available in cosmosdb
https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-sql-query#OffsetLimitClause

@JohnnyFun
Copy link

JohnnyFun commented May 18, 2019

UPDATE
The .net sdk indicated that I need to filter on my partition key, which makes sense. When I did that in the emulator, limit worked as expected. So just seems the emulator just didn't error like the .net sdk did.


Am I missing something silly, or does the emulator not support limit correctly? Was expecting 1 result instead of 2.
image

@vip32
Copy link

vip32 commented May 18, 2019

skip/take (linq) is being implemented in the new v3 cosmos client
Azure/azure-cosmos-dotnet-v3#8

@vip32
Copy link

vip32 commented May 18, 2019

not sure if it will land in the current v2 @bchong95 ?

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