[Developers] query for values vs name/id

Tim Sturge tsturge at metaweb.com
Thu May 24 17:40:29 UTC 2007


I realize I missed /type/datetime from the list of value types. There's 
also /type/value which is a placeholder for an unspecified thing known 
to be a value, but it is very rarely used.

Tim

Tim Sturge wrote:
> The shortcut:
>
> "/music/artist/active_start": [{}]
>
> The explanation:
>
> There's a bit of a trick to this. MQL divides the world into "values" 
> and "objects". If you look at the expected_type of a property (try the query
>
> { "query0":
> { "query":
> { "id": "<a-property-like-/music/artist/active_start>",
> "type": "/type/property",
> "expected_type": null
> }
> }
> }
>
> You will find out if a property expects a value (one of /type/id, 
> /type/key, /type/text, /type/rawstring, /type/int, /type/float, 
> /type/boolean and /type/uri) or an object (anything else)
>
> Then you can ask
>
> [{ "name": null, "id": null, "type": [], "optional": true }]
>
> for the objects and
>
> [{ "value": null, "type": null, "optional": true }]
>
> for the values. (the optional: true ensures the query doesn't fail if 
> the property is missing)
>
> [{}]
>
> asks MQL to automatically inspect the expected_type for you and insert 
> one or other of the clauses you see above, depending on which is 
> appropriate. It's what we use internally 90% of the time.
>
> Tim
>
> Steve Sak wrote:
>   
>> Given that I've performed a query to get the properties of some class,
>> say /music/artist and now want to get the "values" and maybe some other
>> attributes of those properties what does the query look like?  The
>> problem I'm running into is when asking for attributes explicitly I
>> can't tell if the property refers to a primitive attibute or another
>> object.  Perhaps I'm just missing something obvious.
>>
>> For instance:
>>
>> {"query0": { "query":[{
>> "limit":1,
>> "name":"The Police",
>> "type":"/music/artist",
>> "/music/artist/active_start":[{"name":null,"id":null}],
>> "/music/artist/acquire_webpage":[{"name":null,"id":null}],
>> "/music/artist/album":[{"name":null,"id":null}],
>> "/music/artist/similar_artist":[{"name":null,"id":null}],
>> "/music/artist/origin":[{"name":null,"id":null}],
>> "/music/artist/home_page":[{"name":null,"id":null}],
>> "/music/artist/active_end":[{"name":null,"id":null}],
>> "/music/artist/label":[{"name":null,"id":null}],
>> "/music/artist/artist_similar":[{"name":null,"id":null}],"
>> /music/artist/genre":[{"name":null,"id":null}],
>> "/music/artist/track":[{"name":null,"id":null}],
>> "/music/artist/contribution":[{"name":null,"id":null}],
>> "/music/artist/member":[{"name":null,"id":null}]}]}}
>>
>> gives the error:
>>
>> {
>>    "status": "/mql/status/error",
>>    "messages": [   {
>>       "info":       {
>>          "property": "name",
>>          "expected_type": "/type/datetime"
>>       },
>>       "query": [      {
>>          "/music/artist/active_start": [         {
>>             "error_inside": ".",
>>             "name": null,
>>             "id": null
>>          }],
>>          "/music/artist/acquire_webpage": [         {
>>             "name": null,
>>             "id": null
>>          }],
>>          "limit": 1,
>>          "type": "/music/artist",
>>          "/music/artist/album": [         {
>>             "name": null,
>>             "id": null
>>          }],
>>          "/music/artist/similar_artist": [         {
>>             "name": null,
>>             "id": null
>>          }],
>>          "/music/artist/home_page": [         {
>>             "name": null,
>>             "id": null
>>          }],
>>          "/music/artist/origin": [         {
>>             "name": null,
>>             "id": null
>>          }],
>>          "/music/artist/active_end": [         {
>>             "name": null,
>>             "id": null
>>          }],
>>          "/music/artist/label": [         {
>>             "name": null,
>>             "id": null
>>          }],
>>          "/music/artist/genre": [         {
>>             "name": null,
>>             "id": null
>>          }],
>>          "/music/artist/artist_similar": [         {
>>             "name": null,
>>             "id": null
>>          }],
>>          "/music/artist/track": [         {
>>             "name": null,
>>             "id": null
>>          }],
>>          "/music/artist/contribution": [         {
>>             "name": null,
>>             "id": null
>>          }],
>>          "name": "The Police",
>>          "/music/artist/member": [         {
>>             "name": null,
>>             "id": null
>>          }]
>>       }],
>>       "type": "/mql/error",
>>       "message": "Type /type/datetime does not have property name",
>>       "path": "/music/artist/active_start",
>>       "status": "/mql/status/type_error"
>>    }]
>> }
>> _______________________________________________
>> Developers mailing list
>> Developers at freebase.com
>> http://lists.freebase.com/mailman/listinfo/developers
>>   
>>     
>
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
>   




More information about the Developers mailing list