[Developers] OR operator in query
Christian Hirsch
hirsch.christian at gmail.com
Tue Jun 24 22:12:04 UTC 2008
thanks a lot, this query works quite well. I've changed/reduced it a
little bit so that I get the information I want (see below). It seems
that this is what I was looking for. The only thing is that the
response is quite large... I will see how it goes...
extending MQL so that it allows more complex wildcard queries would
probably be very useful. I had a few cases where I tried a more
complex query in... "*":[...here] and it didn't wok ;-) I can't recall
the exact queries but I'm sure it can be helpful in many cases.
Cheers,
Christian
{
"id" : "/en/the_departed",
"star_star:type" : [
{
"id" : null,
"name" : null,
"properties" : [
{
"expected_type" : null,
"id" : null,
"index" : null,
"master_property" : {
"expected_type" : null,
"i:links" : [
{
"limit" : 100,
"optional" : true,
"source" : {
"/type/reflect/any_master" : [
{
"id" : 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"
}
},
"name" : null,
"optional" : true,
"type" : []
}
],
"id" : null,
"name" : null
},
"target" : {
"id" : "/en/the_departed",
"limit" : 0
}
}
],
"id" : null,
"name" : null,
"optional" : true
},
"name" : null,
"o:links" : [
{
"limit" : 10,
"optional" : true,
"source" : {
"id" : "/en/the_departed",
"limit" : 0
},
"target" : {
"id" : null,
"name" : null,
"type" : []
}
}
],
"optional" : true,
"sort" : "index"
}
]
}
]
}
On Tue, Jun 24, 2008 at 9:57 AM, Warren Harris <warren at metaweb.com> wrote:
> 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
>
>
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
>
>
More information about the Developers
mailing list