gitlw commented :
@piyushGoyal2 Thanks for reporting this issue. I tried using the following experiment and couldn’t reproduce the problem you described in the latest dgraph master.
- Run Dgraph cluster using the latest master branch with Commit SHA-1 : cf7c1e63
- Create the sample data set using the following commands
curl localhost:8180/alter -XPOST -d '
idVal: string @index(exact) .
account: uid @reverse .
firstName: string .
'
curl 'localhost:8180/mutate?commitNow=true' -H 'Content-Type:application/rdf' -XPOST -d '{
set {
_:one <firstName> "One" .
_:one <account> _:two .
_:two <idVal> "idVal" .
_:three <firstName> "Three" .
_:three <account> _:four .
_:four <idVal> "idVal" .
}
}'
- Query the data with this sample program
import io.dgraph.DgraphClient;
import io.dgraph.DgraphGrpc;
import io.dgraph.DgraphProto;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.Metadata;
import io.grpc.stub.MetadataUtils;
import java.util.HashMap;
import java.util.Map;
public class Experiment {
private static final String TEST_HOSTNAME = "localhost";
private static final int TEST_PORT = 9180;
private static DgraphClient createDgraphClient(boolean withAuthHeader) {
ManagedChannel channel =
ManagedChannelBuilder.forAddress(TEST_HOSTNAME, TEST_PORT).usePlaintext(true).build();
DgraphGrpc.DgraphStub stub = DgraphGrpc.newStub(channel);
if (withAuthHeader) {
Metadata metadata = new Metadata();
metadata.put(
Metadata.Key.of("auth-token", Metadata.ASCII_STRING_MARSHALLER), "the-auth-token-value");
stub = MetadataUtils.attachHeaders(stub, metadata);
}
return new DgraphClient(stub);
}
public static void main(String[] args) {
DgraphClient dgraphClient = createDgraphClient(false);
final String query = " query all($idVal: string, $userID: string)" +
"{\n" +
" run(func: eq(idVal, $idVal)) {\n" +
" uid\n" +
" idVal\n" +
" ~account @filter(uid($userID)){\n" +
" uid\n" +
" firstName\n" +
" }\n" +
" }\n"
+ "}";
final Map<String, String> parameterMap = new HashMap<>();
parameterMap.put("$idVal","idVal");
parameterMap.put("$userID", "0x01");
DgraphProto.Response response = dgraphClient.newReadOnlyTransaction().queryWithVars(query, parameterMap);
System.out.println(response.getJson().toStringUtf8());
}
}
And the result I get is
{"run":[{"uid":"0x2","idVal":"idVal","~account":[{"uid":"0x1","firstName":"One"}]},{"uid":"0x4","idVal":"idVal"}]}
If I remove the @filter(uid(…)) part of the query, the result I get will be
{"run":[{"uid":"0x2","idVal":"idVal","~account":[{"uid":"0x1","firstName":"One"}]},{"uid":"0x4","idVal":"idVal","~account":[{"uid":"0x3","firstName":"Three"}]}]}
Thus the result seems correct to me.
I’m closing this issue for now, and feel free to reopen if you are still seeing this problem.