[Developers] OR operator in query

David Flanagan david at davidflanagan.com
Fri Jun 20 20:26:04 UTC 2008


Christian Hirsch wrote:
> 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?

Its not that the OR isn't working, its just that wildcard expansion is 
only done based on an explicit type property.  Since it doesn't see a 
bare type property on the left, it only expands the properties of 
/type/object.

Arthur's suggestion for using reflection is a good one, though his use 
of link:* returns much more data than you are probably interested in.

Here's another query you could use:

[
   {
     "master_property" : null,
     "source" : {
       "id" : "/en/the_departed"
     },
     "target" : null,
     "target_value":null,
     "type" : "/type/link"
   }
]

Note, however, that this query only finds outgoing links from the movie 
to other objects, not incoming links from other objects.  To find those, 
you'd also have to submit a query where the movie is the target and the 
source is null.

Even though two queries are required here, keep in mind that you can 
submit them to mqlread in a single HTTP transaction.

I'm just about finished with a new draft of my MQL tutorial.  It covers 
link queries and reflective queries, among other new features.  I'll 
post a message here when it is ready for download and review.

	David


> Cheers,
> Christian
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
> 



More information about the Developers mailing list