Questions regarding `QueryByExample` structure and handling
geel9 opened this issue · comments
Joshua Coffey commented
Hello,
I have some questions regarding the proper handling of QueryByExample
objects.
I understand that many of these questions may not yet have answers, but I'd appreciate any insight that can be provided.
- Are the
@context
andtype
fields required or optional? - What is the datatype of these fields?
- I am operating under the assumption that they are both
string | string[]
-- is this fair?
- I am operating under the assumption that they are both
- How are the
@context
andtype
fields to be handled?- I am operating under the assumption that every value in the example
@context
array (whether it be expressed as an array of strings or a string itself) must be present in the credential's@context
array, but additional values may be present in the credential's@context
array. Is this fair? - I am operating under an equal assumption for the
type
field.
- I am operating under the assumption that every value in the example
- Is
credentialSubject
limited to onlyid
andname
fields, or is it intended for arbitrary key/values to query against the credential'scredentialSubject
?- My intuition tells me that any key/value pairs are valid, but the comment above it in Example 2 states
You can request a specific subject id
, which implies that that is the only intended usage.
- My intuition tells me that any key/value pairs are valid, but the comment above it in Example 2 states
- Assuming
credentialSubject
is not limited toid
andname
, how is comparison meant to be handled?- Comparisons of primitives is intuitive, but stringy equality (does
5
match"5"
?) should be clarified. - Comparisons of objects is also intuitive -- just recurse.
- I am assuming, however, that all object comparisons (including the top-level
example.credentialSubject
tocredential.credentialSubject
comparison itself) are loose in the sense that the object on the credential may have additional fields not specified by the example object.
- I am assuming, however, that all object comparisons (including the top-level
- How should one perform a comparison of arrays?
- See below
- Comparisons of primitives is intuitive, but stringy equality (does
Array Comparison in credentialSubject
(This is all assuming that the credentialSubject
field in the example query is not restricted to id
and name
fields)
Given the following query:
{
"type": "QueryByExample",
"credentialQuery": {
"example": {
"credentialSubject": {
"primitive_array_one": [0, 1, 2],
"primitive_array_two": [10, 11, 12],
"complex_array": [
{
"a": 1
},
{
"b": 2
}
]
}
}
}
}
And the following credentialSubject
from a VerifiableCredential:
{
"credentialSubject": {
"id": "whatever",
"primitive_array_one": [0, 1, 2, 3],
"primitive_array_two": [12, 11, 10],
"complex_array": [
{
"a": 1,
"b": 2,
},
{
"b": 3
}
]
}
}
It's not entirely clear how to handle this query by example.
primitive_array_one
- The credential's
primitive_array_one
contains all values of the example'sprimitive_array_one
, in the same order and position, but it has additional entries.
- The credential's
primitive_array_two
- The credential's
primitive_array_two
contains all values of the example'sprimitive_array_two
, and has no additional values, but they are not in the same order.
- The credential's
complex_array
- The example is looking for an object with an
a
value equal to1
, and an object with ab
value equal to2
.- The credential does, in fact, have an object with an
a
value equal to1
, and an object with ab
value equal to2
. - However, they're the same object, which likely isn't what the person who wrote the query was intending.
- The credential does, in fact, have an object with an
- The example is looking for an object with an