Hello,
I am finding working with facets a bit cumbersome. Consider this example: the IT department of a company tracks which kind of devices are assigned to who (laptop, mobile, keys,…); a person uses multiple devices and an application tracks which devices the person is currently using and which one it used before (using facets).
to get the list of devices for a person I will write something like this:
query {
q(func:eq(name,"John Smith")) {
uid
hasDevice @facets(until)
{
uid
}
}
}
and the reply would be something like
{
"data": {
"q": [
{
"uid": "0x2b02",
"hasDevice": [
{
"uid": "0x2b06"
},
{
"uid": "0x2b07"
},
{
"uid": "0x2b09"
},
{
"uid": "0x2b11"
},
{
"uid": "0x2b13"
},
{
"uid": "0x2b35"
},
{
"uid": "0x2b5a"
},
{
"uid": "0x53489"
},
{
"uid": "0x534ae"
},
{
"uid": "0x534b0"
},
{
"uid": "0x5577b"
},
{
"uid": "0x1b5129"
},
{
"uid": "0x1b5236"
}
],
"hasDevice|until": {
"2": "2020-01-31T00:00:00Z",
"8": "2020-05-25T00:00:00Z"
}
}
]
},
....
}
From a user standpoint the structure of the reply for the facets looks baroque and it requires custom code to assemble the results.
For example something like the following would be easier to deal with:
{
"data": {
"q": [
{
"uid": "0x2b02",
"hasDevice": [
{
"uid": "0x2b06"
},
{
"uid": "0x2b07"
},
{
"uid": "0x2b09"
"@until": "2020-01-31T00:00:00Z"
},
{
"uid": "0x2b11"
},
{
"uid": "0x2b13"
},
{
"uid": "0x2b35"
},
{
"uid": "0x2b5a"
},
{
"uid": "0x53489"
},
{
"uid": "0x534ae"
"@until": "2020-05-25T00:00:00Z"
},
{
"uid": "0x534b0"
},
{
"uid": "0x5577b"
},
{
"uid": "0x1b5129"
},
{
"uid": "0x1b5236"
}
]
}
]
},
....
}
Would you suggest alternative approach for the above scenario?
Thanks,
Andrea