This brings up the general concept of "default_property"
If I ask for two property values with null and []:
{
"q":{
"query":{
"active_start":null,
"genre":[],
"name":"The Police",
"type":"/music/artist"
}
}
}
I get the response:
{
"q":{
"result":{
"active_start":"1977-01",
"genre":["Rock music","Ska","Reggae"],
"name":"The Police",
"type":"/music/artist"
},
"status":"/mql/status/ok"
},
"status":"200 OK"
}
What's interesting here is that "genre" is a reference to other topics and "active_start" is a primitive datetime type. But how could we possibly know this? And how does MQL know to put the name of the genre topic, instead of the id? The answer is in the "default_property" of a type.
Let's inspect these properties:
{
"q":{
"query":{
"id":"/music/artist",
"properties":[{
"expected_type":{
"default_property":null,
"id":null
},
"id":null,
"id|=":["/music/artist/genre","/music/artist/active_start"]
}],
"type":"/type/type"
}
}
}
And the response:
{
"q":{
"result":{
"id":"/music/artist",
"properties":[{
"expected_type":{
"default_property":"value",
"id":"/type/datetime"
},
"id":"/music/artist/active_start"
},{
"expected_type":{
"default_property":null,
"id":"/music/genre"
},
"id":"/music/artist/genre"
}],
"type":"/type/type"
},
"status":"/mql/status/ok"
},
"status":"200 OK"
}
Note that "active_start" is a datetime, and the default property is "value".. in the case of "/music/genre", there is no "default_property" - when this happens, MQL defaults to the "name" property.
Because MQL has this built in, you get the "right" value if you don't expand the property clause (i.e. if you just put 'null' or '[]')
But MQL has a way of blowing out the default property and automatically asking for the right set of properties - it's {} or [{}] instead of null or []:
{
"q":{
"query":{
"active_start":{},
"genre":[{}],
"name":"The Police",
"type":"/music/artist"
}
}
}
Look at the result:
{
"q":{
"result":{
"active_start":{
"type":"/type/datetime",
"value":"1977-01"
},
"genre":[{
"id":"#9202a8c04000641f8000000000032ba7",
"name":"Rock music",
"type":["/common/topic","/music/genre"]
},{
"id":"#9202a8c04000641f8000000000035edb",
"name":"Ska",
"type":["/common/topic","/music/genre"]
},{
"id":"#9202a8c04000641f8000000000032eca",
"name":"Reggae",
"type":["/common/topic","/music/genre"]
}],
"name":"The Police",
"type":"/music/artist"
},
"status":"/mql/status/ok"
},
"status":"200 OK"
}
For all values, it includes "id" and "type" - for primitive types, it includes "name" or "value" as appropriate.
But what you're doing (expanding all the properties of a particular type) can actually be accomplished with the "*" property, which expands to all properties. I'll let you run the query because the response is quite large:
{
"q":{
"query":{
"*":[{}],
"name":"The Police",
"type":"/music/artist"
}
}
}
More information on how to query schema objects, their properties, user interaction with those objects, and the links between them can be found in the Schema Introspection Cookbook.
Search Help Center
Discussions
There are no conversations on this topic. Would you like to start one?
Start the Discussion »