When work random query in dgraph cloud

Not working in dgraph cloud but it’s work in my local
Give me solution i need this solution asap in dgraph cloud
Thanks
{
q(func: type(Person), random: 5) {
name
uid
}
}

Please, share the steps you made. Can you also check the version of Dgraph in the Cloud?

IIRC, the random feature was added to 21.12, and the cloud is on 21.03.

As a workaround, client side you could generate 5 random numbers within the total numbers of records and issue five queries with first: 1 offset: x.

1 Like

the cloud is on 21.03
we are using dedicated server

As said by Matthew, this is related to the release. The Random feature was Merged shortly after this version that is in the cloud. There is still no forecast of cloud version upgrade.

If the issue is another do this:

Run this to check if there is any dataset anyway.

{
q(func: has(name), first: 5) {
   name
   uid
   dgraph.type
  }
}

If you see results and there is node with dgraph.type = “Person”.

can anyone confirm whether or not random: x should also be currently working for graphql queries on dgraph cloud?
because I’m currently seeing message: 'Unknown argument "random" but I thought cloud has the latest version?

I have confirmed this PR is not in the current version. My guess is it was added into the (short-lived 21.12 release which had issues so is being slowly re-incorporated into a more stable baseline of v23/v24 now.

We are also reviewing community-supplied PRs right now, and there is great stuff in there. If you are willing to merge feat(Query): Add random keyword in DQL by Samyak2 · Pull Request #7693 · dgraph-io/dgraph · GitHub into the current v23 release tag and test it to be sure it works, that would be most helpful.

You could of course also run that custom version of dgraph. Building dgraph is quite trivial and easy to work on.

In the meantime, you could add a lambda or client-side logic to pull all UIDs, select random ones, and use that.

1 Like

I can’t set up a lambda for this so still need it via a dgraph built-in