[Developers] OR operator in query
Warren Harris
warren at metaweb.com
Mon Jun 23 21:57:16 UTC 2008
A little while ago, I too tried to duplicate all the information
returned for our topic pages in a single schema query. Here's what I
came up with (sorry, it's rather unwieldy):
{
"id":"/en/the_departed",
"star_star:type":[{
"name":null, "id":null, "guid":null,
"properties":[{
"optional":true,
"id":null, "name":null,
"index" : null, "sort":"index", "expected_type":null,
"o:links":[{
"source": {"id": "/en/the_departed","limit":0},
"target_value":null,
"target":{
"id":null, "guid":null, "name":null,
"/type/reflect/any_master":[{
"name":null, "id":null, "guid":null,
"link":{"master_property":{
"/freebase/property_hints/
disambiguator":true,
"/type/property/expected_type":null,
"id":null, "name":null},
"target": {"id": "/en/
the_departed","optional":"forbidden"}},
"optional":true
}],
"/type/reflect/any_value":[{
"value":null, "type":null,
"link":{"master_property":{
"/freebase/property_hints/
disambiguator":true,
"id":null, "name":null},
"target": {"id": "/en/
the_departed","optional":"forbidden"}},
"optional":true
}],
"/common/image/size":{"x":null, "y":null, "optional":true},
"/common/image/image_caption": [],
"/common/webpage/description": []
},
"limit":10,
"optional":true
}],
"master_property":{
"id":null, "name":null, "expected_type":null,
"i:links":[{
"target": {"id": "/en/the_departed","limit":0},
"target_value":null,
"source":{
"id":null, "guid":null, "name":null,
"/type/reflect/any_master":[{
"name":null, "id":null, "guid":null,
"link":{"master_property":{
"/freebase/property_hints/
disambiguator":true,
"/type/property/expected_type":null,
"id":null, "name":null},
"target": {"id": "/en/
the_departed","optional":"forbidden"}},
"optional":true
}],
"/type/reflect/any_value":[{
"value":null, "type":null,
"link":{"master_property":{
"/freebase/property_hints/
disambiguator":true,
"/type/property/expected_type":null,
"id":null, "name":null}},
"optional":true
}],
"/common/image/size":{"x":null, "y":null,
"optional":true},
"/common/image/image_caption": [],
"/common/webpage/description": []
},
"limit":10,
"optional":true
}],
"optional":true
}
}]
}]
}
We have been considering extending MQL to simplify this kind of query
via the wildcard notation:
{ "id" : "/en/the_departed",
"*" : [{
"id": null,
"index": null,
"guid": null,
"name": null,
"link": {"master_property": {
"/freebase/property_hints/disambiguator":true,
"/type/property/expected_type":null,
"id":null, "name":null
}},
"/common/image/size":{"x":null, "y":null, "optional":true},
"/common/image/image_caption": [],
"/common/webpage/description": [],
"value": null
}]
}
I'd be very interested in your feedback on this proposed feature.
Warren
On Jun 19, 2008, at 8:03 PM, Christian Hirsch wrote:
> Hi,
>
> I'm starting with a topic id (e.g. /en/the_departed) and like to query
> all of its properties (e.g. all actors starring in the movie, awards
> won, etc.).
>
> At the moment I'm using separate queries for each type which is
> associated with the topic to get all these information, e.g.:
>
> {
> "*" : [],
> "id" : "/en/the_departed",
> "type" : "/film/film"
> }
>
> ------------
>
> {
> "*" : [],
> "id" : "/en/the_departed",
> "type" : "/award/award_winning_work"
> }
>
> ------------
>
> etc.
>
> This works well but is not very efficient.
> First of all a query is needed to get the types of the topic:
> {
> "id" : "/en/the_departed",
> "type" : []
> }
>
> ...and then a query is needed for each type as described above.
>
>
> What would be the best way to reduce the number of queries?
>
> I just tried to use an OR operator, e.g.:
>
> {
> "*" : [],
> "id" : "/en/the_departed",
> "type" : [],
> "type|=" : [
> "/film/film",
> "/award/award_winning_work"
> ]
> }
>
> but it doesn't give the desired results. Is there some syntax error,
> or does the OR not work in this case?
>
> Cheers,
> Christian
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3739 bytes
Desc: not available
Url : http://lists.freebase.com/pipermail/developers/attachments/20080623/cbd4a1a9/attachment.bin
More information about the Developers
mailing list