I'm trying to find a way to randomize a dataset (which I can do), but then paginate it so that I don't have to send the entire list down to the client.
Currently, I have an API that simply takes in the filter criteria, creates a cypher query and returns the dataset. The client passes in a SKIP and LIMIT in order to keep up with where they are. The dataset is User Profiles. It's been asked of me if it's possible to randomize the list. I did some testing and adding a rand to the query works good if I want to pull the entire dataset...but when I try to use SKIP and LIMIT I start to get duplicates.
MATCH (p:Person) WITH p, rand() AS r ORDER BY r RETURN p.userId, p.firstName SKIP 1 LIMIT 25
One option that I had thought about was randomizing the entries on the client side so that the server would send the results exactly the same but the user would see their LIMIT quantity randomized. The problem is that right now, I have mobile clients only downloading 4 profiles at a time (which would be pretty obvious that the randomizing is only on the LIMIT query.
I was about to just change the number of profiles downloaded on mobile devices to something higher so it wouldn't be so obvious...but I wanted to see if there was something already built in that could do something like this for me. Especially considering that if that's possible, I can implement it on the server side and not require an app update.