What I want to do
I want to execute a Dgraph query to fetch data from a specific block (let’s call it “l”) while applying filters, and then further filter the results from this “l” block and return only the data that matches the secondary filter conditions. I want to ensure that the data block of the query contains only data from the “l” block.
What I did
query:
query Instances($page: int, $offset: int, $state: string) {
l(func: type(“DataInstance”), first: $page, offset: $offset) @filter(regexp(state, /^saved/)) @cascade {
v as uid
instancetable @filter(regexp(name, /(.2.)/i)) {
name
}
state
}
data(func: uid(v)) @recurse(loop: false) {
uid
instancetable
name
state
}
}
result:
“data”: {
“l”: [
{
“uid”: “0x42158e”,
“instancetable”: {
“name”: “234”
},
“state”: “saved_table_deployed”
}
],
“data”: [
{
“uid”: “0x42158e”,
“instancetable”: {
“uid”: “0x42157c”,
“name”: “234”,
“state”: “”
},
“state”: “saved_table_deployed”
},
{
“uid”: “0x4261cd”,
“instancetable”: {
“uid”: “0x3cdc65”,
“name”: “WaterproofingAndDrainageAccessory”,
“state”: “”
},
“state”: “saved_table_deployed”
},
{
“uid”: “0x4261d2”,
“instancetable”: {
“uid”: “0x3cdd8f”,
“name”: “WingWall”,
“state”: “”
},
“state”: “saved_table_deployed”
}
]
}
Dgraph metadata
dgraph version
v20.07.2