Closed kevinkle closed 4 years ago
{
set{
_:a <km> "ATCC" .
_:b <km> "ATCG" .
_:c <km> "ATGG" .
_:a <fd> _:b (type="a", value=0) .
_:b <fd> _:c (type="a", value=1) .
_:c <fd> _:b (type="a", value=2) .
_:b <fd> _:c (type="a", value=3) .
}
}
{
q(func: has(km)){
expand(_all_)
}
}
{
"extensions": {
"server_latency": {
"parsing_ns": 12840,
"processing_ns": 2450020,
"encoding_ns": 957272
},
"txn": {
"start_ts": 24
}
},
"data": {
"q": [
{
"fd": [
{
"fd|type": "a",
"fd|value": 0
}
],
"km": "ATCC"
},
{
"fd": [
{
"fd|type": "a",
"fd|value": 3
}
],
"km": "ATCG"
},
{
"fd": [
{
"fd|type": "a",
"fd|value": 2
}
],
"km": "ATGG"
}
]
}
}
{
set{
_:a <km> "ATCC" .
_:b <km> "ATCG" .
_:c <km> "ATGG" .
_:a <fd> _:b (type="a", value=0) .
_:b <fd> _:c (type="a", value=1) .
_:c <fd> _:b (type="a", value=2) .
_:b <fd> _:c (type="a", value=3) .
}
}
{
q(func: has(km)){
uid
expand(_all_)
}
}
{
path as shortest(from:0x1, to:0x3, numpaths:2, depth:5){
fd
}
path(func: uid(path)){
km
}
}
{
set{
_:a <km> "ATCC" .
_:b <km> "ATCG" .
_:c <km> "ATGG" .
_:a <fd> _:b (type="a", value=0) .
_:b <fd> _:c (type="a", value=1) .
_:c <fd> _:b (type="a", value=2) .
_:b <fd> _:c (type="a", value=3) .
}
}
only generates one edge from ATCG
to ATGG
namely where value=3
{
set{
_:a <km> "ATCC" .
_:b <km> "ATCG" .
_:c <km> "ATGG" .
_:a <e> _:e1 .
_:e1 <src> _:a .
_:e1 <tgt> _:b .
_:e1 <type> "genome_a" .
_:e1 <value> "0" .
_:b <e> _:e2 .
_:e2 <src> _:b .
_:e2 <tgt> _:c .
_:e2 <type> "genome_a" .
_:e2 <value> "1" .
_:c <e> _:e3 .
_:e3 <src> _:c .
_:e3 <tgt> _:b .
_:e3 <type> "genome_a" .
_:e3 <value> "2" .
_:b <e> _:e4 .
_:e4 <src> _:b .
_:e4 <tgt> _:c .
_:e4 <type> "genome_a" .
_:e4 <value> "3" .
}
}
{
q(func: has(km)){
expand(_all_) {
expand(_all_)
}
}
}
{
"extensions": {
"server_latency": {
"parsing_ns": 26517,
"processing_ns": 3619033,
"encoding_ns": 1500679
},
"txn": {
"start_ts": 7
}
},
"data": {
"q": [
{
"km": "ATCC",
"e": [
{
"value": "0",
"type": "genome_a"
}
]
},
{
"km": "ATCG",
"e": [
{
"value": "1",
"type": "genome_a"
},
{
"value": "3",
"type": "genome_a"
}
]
},
{
"km": "ATGG",
"e": [
{
"value": "2",
"type": "genome_a"
}
]
}
]
}
}
this is better:
{
q(func: has(km)){
expand(_all_) {
expand(_all_) {
expand(_all_)
}
}
}
}
{
"extensions": {
"server_latency": {
"parsing_ns": 12656,
"processing_ns": 3567880,
"encoding_ns": 1076056
},
"txn": {
"start_ts": 12
}
},
"data": {
"q": [
{
"km": "ATCC",
"e": [
{
"src": [
{
"km": "ATCC"
}
],
"value": "0",
"tgt": [
{
"km": "ATCG"
}
],
"type": "genome_a"
}
]
},
{
"km": "ATCG",
"e": [
{
"src": [
{
"km": "ATCG"
}
],
"value": "1",
"tgt": [
{
"km": "ATGG"
}
],
"type": "genome_a"
},
{
"src": [
{
"km": "ATCG"
}
],
"value": "3",
"tgt": [
{
"km": "ATGG"
}
],
"type": "genome_a"
}
]
},
{
"km": "ATGG",
"e": [
{
"src": [
{
"km": "ATGG"
}
],
"value": "2",
"tgt": [
{
"km": "ATCG"
}
],
"type": "genome_a"
}
]
}
]
}
}
maybe simpler?
{
set{
_:a <km> "ATCC" .
_:b <km> "ATCG" .
_:c <km> "ATGG" .
_:a <e> _:e1 .
_:e1 <e> _:b .
_:e1 <type> "genome_a" .
_:e1 <value> "0" .
_:b <e> _:e2 .
_:e2 <e> _:c .
_:e2 <type> "genome_a" .
_:e2 <value> "1" .
_:c <e> _:e3 .
_:e3 <e> _:b .
_:e3 <type> "genome_a" .
_:e3 <value> "2" .
_:b <e> _:e4 .
_:e4 <e> _:c .
_:e4 <type> "genome_a" .
_:e4 <value> "3" .
}
}
query
{
path as shortest(from: 0x2, to:0x4){
e
}
path(func: uid(path)){
km
}
}
returns
{
"extensions": {
"server_latency": {
"parsing_ns": 26559,
"processing_ns": 2813637,
"encoding_ns": 1114559
},
"txn": {
"start_ts": 11
}
},
"data": {
"path": [
{
"km": "ATCC"
},
{
"km": "ATCG"
},
{
"km": "ATGG"
}
],
"_path_": [
{
"e": [
{
"e": [
{
"e": [
{
"e": [
{
"uid": "0x4"
}
],
"uid": "0x1"
}
],
"uid": "0x3"
}
],
"uid": "0x5"
}
],
"uid": "0x2"
}
]
}
}
recurse on this
{
f(func: uid(0x2)) @recurse{
e
km
type
value
}
}
{
"extensions": {
"server_latency": {
"parsing_ns": 15368,
"processing_ns": 3463893,
"encoding_ns": 1054545
},
"txn": {
"start_ts": 57
}
},
"data": {
"f": [
{
"e": [
{
"e": [
{
"e": [
{
"e": [
{
"e": [
{
"e": [
{
"km": "ATCG"
}
],
"type": "genome_a",
"value": "2"
}
],
"km": "ATGG"
}
],
"type": "genome_a",
"value": "3"
},
{
"e": [
{
"e": [
{
"e": [
{
"km": "ATCG"
}
],
"type": "genome_a",
"value": "2"
}
],
"km": "ATGG"
}
],
"type": "genome_a",
"value": "1"
}
],
"km": "ATCG"
}
],
"type": "genome_a",
"value": "0"
}
],
"km": "ATCC"
}
]
}
}
this works:
{
f(func: eq(km, "ATCC")) {
km
e @filter(eq(type, "genome_a") AND eq(value, 0)) {
e {
km
e @filter(eq(type, "genome_a") AND eq(value, 1)) {
e {
km
e @filter(eq(type, "genome_a") AND eq(value, 2)) {
e {
km
e @filter(eq(type, "genome_a") AND eq(value, 3)) {
e {
km
}
}
}
}
}
}
}
}
}
}
returning
{
"extensions": {
"server_latency": {
"parsing_ns": 49376,
"processing_ns": 4244832,
"encoding_ns": 1138359
},
"txn": {
"start_ts": 115
}
},
"data": {
"f": [
{
"km": "ATCC",
"e": [
{
"e": [
{
"km": "ATCG",
"e": [
{
"e": [
{
"km": "ATGG",
"e": [
{
"e": [
{
"km": "ATCG",
"e": [
{
"e": [
{
"km": "ATGG"
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
}
{
set{
_:n <km> "AAA" .
<0x1> <e> _:e .
_:e <e> _:n .
_:e <type> "genome_b" .
_:e <value> "0" .
_:n <e> _:e2 .
_:e2 <e> <0x3> .
_:e2 <type> "genome_b" .
_:e2 <value> "1" .
}
}
query:
{
q(func: eq(km, "ATCC")){
e {
uid
type
value
@filter(
eq(type, "genome_b") AND eq(value, 0)
)
e @filter(eq(km, "AAA"))
}
}
}
doesnt work as intended
Needed to move filter up a level
{
q(func: eq(km, "ATCC")){
e @filter(
eq(type, "genome_b") AND eq(value, 0)
){
uid
type
value
e @filter(eq(km, "AAA"))
}
}
}
And
{
q(func: eq(km, "ATCC")) {
e @filter(
eq(type, "genome_b") AND eq(value, 0)
){
uid
type
value
e @filter(eq(km, "BBB"))
}
}
}
also doesnt filter correctly since BBB
doesnt exist
Needed @cascade
directive
{
q(func: eq(km, "ATCC")) @cascade{
e @filter(
eq(type, "genome_b") AND eq(value, 0)
){
uid
type
value
e @filter(eq(km, "AAA"))
}
}
}