Im getting there. Could you tell me why if the document is not found, the upsert doesn’t create a new Result. It attached the the context to the existing one. Here is the upsert;
upsert{
query{
srch as r(func: eq(querystring,"(1efficiency~x)")){
uid
result @cascade{
ruid as uid
document@filter(eq(doc.id, "2318563")){
uid
doc.id
}
}
}
doc as p(func: eq(doc.id,"2318562")){uid}
ctx0 as c0(func: eq(context.id,"2318563-641318")){uid}
ctx1 as c1(func: eq(context.id,"2318563-641328")){uid}
ctx2 as c2(func: eq(context.id,"2318563-641722")){uid}
}
mutation{
set{
uid(srch) <dgraph.type> "Search" .
uid(srch) <querystring> "(1efficiency~x)" .
uid(srch) <result> uid(ruid) .
uid(ruid) <document> uid(doc) .
uid(ruid) <dgraph.type> "Result" .
uid(ruid) <result.context> uid(ctx0) .
uid(ruid) <result.context> uid(ctx1) .
uid(ruid) <result.context> uid(ctx2) .
uid(doc) <dgraph.type> "Document" .
uid(doc) <doc.id> "2318563" .
}
}
}
Here is the Json response when I the doc doesn't exist
{
"data": {
"code": "Success",
"message": "Done",
"queries": {
"r": [
{
"uid": "0x46f557"
}
],
"p": [
{
"uid": "0x46f55c"
}
],
"c0": [],
"c1": [],
"c2": []
},
"uids": {
"uid(ctx0)": "0x46f560",
"uid(ctx1)": "0x46f561",
"uid(ctx2)": "0x46f562"
}
},
"extensions": {
"server_latency": {
"parsing_ns": 59323,
"processing_ns": 19719788,
"encoding_ns": 8199,
"assign_timestamp_ns": 565345,
"total_ns": 20583389
},
"txn": {
"start_ts": 3511372,
"commit_ts": 3511373,
"preds": [
"1-dgraph.type",
"1-doc.id",
"1-document",
"1-querystring",
"1-result",
"1-result.context"
]
}
}
}
and here is the json when it does exist.
{
"data": {
"code": "Success",
"message": "Done",
"queries": {
"r": [
{
"uid": "0x46f557",
"result": [
{
"uid": "0x46f559",
"document": [
{
"uid": "0x46f55c",
"doc.id": 2318563
}
]
}
]
}
],
"p": [
{
"uid": "0x46f55c"
},
{
"uid": "0x46f565"
}
],
"c0": [
{
"uid": "0x46f55d"
}
],
"c1": [
{
"uid": "0x46f55e"
}
],
"c2": [
{
"uid": "0x46f55f"
}
]
},
"uids": {}
},
"extensions": {
"server_latency": {
"parsing_ns": 46657,
"processing_ns": 19766848,
"encoding_ns": 17991,
"assign_timestamp_ns": 392200,
"total_ns": 20409347
},
"txn": {
"start_ts": 3511412,
"commit_ts": 3511413,
"preds": [
"1-dgraph.type",
"1-doc.id",
"1-document",
"1-querystring",
"1-result",
"1-result.context"
]
}
}
}