[Developers] Results in [ ]

Christopher R. Maden crism at metaweb.com
Fri Feb 1 09:08:43 UTC 2008


Arthur van Hoff <AVH at zing.net> wrote:
> This may be a dumb question. Check out this query:
> 
> For feed_media_format it returns an array of ids, but for the genre
> property it returns an array of names (which is what I excepted in both
> cases). Why the difference?

Not a dumb question, but a subtlety of MQL.

When asked to display a simple string form of a property value, MQL has some rules that it follows.

If the property has a simple value, like a text or integer value, it displays the value.

Then, for most link properties, it shows the display name of the linked object.  (This is why some CVT property values just show up as “null”; those CVTs don’t have display names.)

But for some types of linked objects, MQL will use a different property, rather than the name, to show a value.  Take a look at <URL: http://www.freebase.com/view/type/media_type?admin=1 >, the type expected by the feed_media_format property.  The default property is set to “id” — in other words, for any media type value, the ID of the target node will be given, rather than the English display name.

Generally, if one wants reliably an ID of a target or a name of a target, the query should be explicit about that:

"property":[{"id":null}]

or

"property":[{"name":null}]

Those will always do what is expected, regardless of any changes to the type definition.

~Chris
-- 
Christopher R. Maden
Data Architect
Metaweb Technologies, Inc.
<URL: http://www.metaweb.com/ >


More information about the Developers mailing list