For best performance and scalability, avoid using this; instead create another view whose keys include the thing you want to sort by. But it’s not always possible to do this; sometimes you really need to specify a key range one way and then sort a different way. That’s what 'sortDescriptors' feature is for
emit(@[project,archived,map,status],@[title,email,creationDate,modifiedDate]); //first 3 keys are very important filters
query.postFilter = [NSPredicate predicateWithFormat:@"key[3] == %@",@"created"];
query.limit = 50;
[query run:nil]
Thanks
On Aug 25, 2015, at 7:42 AM, Aj <ajith...@icloud.com> wrote:
Sometimes you really need to specify a key range one way and then sort a different way & paginate the query results. How can I achieve this? Applying sortDescriptor + limit to query doesn't gives me expected result.
I observed that applying "limit + postFilter" gives gives limit+1 results. Shall I file a issue?
However, the query isn’t going to be very efficient, since it’ll be generating the entire result set, sorting it, and then throwing away the results outside the current page. It may be better for you to keep the entire result set in memory and just display the relevant portions.
emit(@[project,archived,lastModified],@[email,status])
emit(@[project,archived,title],@[email,status])
emit(@[project,archived,responsible],@[email,status])
emit(@[project,archived,dueDate],@[email,status])
emit(@[project,archived,map,lastModified],@[email,status])
emit(@[project,archived,map,title],@[email,status])
emit(@[project,archived,map,responsible],@[email,status])
emit(@[project,archived,map,dueDate],@[email,status])I'll still have to use 'postFilter' on the "value" objects. Will the query going to be inefficient even in this case? Not using "postFilter" is going to result in lot of views (see here https://friendpaste.com/2aNqHn0Hg8mwLHgTsDuRuC )
emit(@[project,email,status],@1)
emit(@[project,status,email],@1)
And, I was wondering if there is any way to avoid writing two views for above case? I only swapped index of objects inside key array.