[Developers] OR operator in query

Christian Hirsch hirsch.christian at gmail.com
Mon Jun 23 04:34:37 UTC 2008


Thanks. Can this query also be modified so that it also returns the
CVT's? In the case of a movie it doesn't for example return the
starring actors or the awards won. Maybe a change to "type" :
"/type/link" is needed?

Also, could the query be modified so that it additionally returns the
actual label of the properties? E.g. in the response below, it would
be nice to get the label "Directed by" additionally to the id
"/film/film/directed_by" (without additional queries).

  ...
  {
    "master_property" : "/film/film/directed_by",
    "operation" : "insert",
    "source" : {
      "id" : "/en/the_departed"
    },
    "target" : [
      {
        "id" : "/en/martin_scorsese",
        "name" : "Martin Scorsese",
      }
    ],
    "target_value" : null,
    "type" : "/type/link"
  },
  ...


Thanks,
Christian


On Sat, Jun 21, 2008 at 8:26 AM, David Flanagan <david at davidflanagan.com> wrote:
> 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
>>
>
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
>


More information about the Developers mailing list