[Developers] Creating new Relationships
Bryan Cheung
bryan.cheung at metaweb.com
Wed Feb 20 23:30:50 UTC 2008
1) Since concepts can have multiple types, you will always need to
specify the type that you are populating values for. Alternatively,
you can use the instance ID and the fully qualified property ID for
your query:
{
"query" : {
"id" : movieID,
"story_by" : {
"connect" : "insert",
"id" : personID,
"type" : {
"connect" : "insert",
"id" : "/film/film_contributor"
}
},
"type" : "/film/film"
}
}
and
{
"query" : {
"/film/film/story_by" : {
"connect" : "insert",
"id" : personID,
"type" : {
"connect" : "insert",
"id" : "/film/film_contributor"
}
},
"id" : movieID
}
}
are equivalent queries. The latter is handy when you are populating
values for multiple types for a given instance.
2) When you're connecting the film contributor, MQL, unlike the web
client, does not infer that if the personID you are adding is of type /
film/film_contributor and you should specify it explicitly. If the
person is already typed as a /film/film_contributor, MQL will return
connect:present.
If you wish to programatically find out what the ECT of a property
is, you can query for it like this:
{
"query" : {
"expected_type" : {
"id" : null,
"name" : null
},
"id" : "/film/film/story_by",
"type" : "/type/property"
}
}
Bryan
On Feb 20, 2008, at 2:53 PM, Christian Hirsch wrote:
> Hi,
> I am developing an application which should be able to create new
> relationships between existing topics. For example connect a movie
> to a person with the relationship "story_by". I am trying to
> establish this with 3 known variables:
> - the "source" id, e.g. the movie ID
> - the "sink" id, e.g. the person ID
> - the name of the relationship, e.g. "story_by"
>
> As I found out, these 3 variables are not enough to create the
> relationshp (if I'm wrong please correct me ;)... I have two
> questions:
>
> 1)
> creating the relationship with the 3 mentioned variables alone
> doesn't work. The following write request is missing the correct type
>
> {
> "id" : "movieID",
> "story_by" : {
> "connect" : "insert",
> "id" : "personID"
> },
> }
>
> this works:
>
> {
> "id" : "movieID",
> "story_by" : {
> "connect" : "insert",
> "id" : "personID"
> },
> "type" : "/film/film"
> }
>
> So my question is: given only the 3 variables, What is the best way
> to find out, that I need to use the type "/film/film"?
>
>
> 2)
> the second write request above is still not enough to create the new
> relationship. I need to assign a new type to the person. In this
> example I need to do the following:
>
> {
> "id" : "personID",
> "type" : {
> "connect" : "insert",
> "id" : "/film/film_story_contributor"
> }
> }
>
> The question is again: how do I find out that the new type which
> needs to be assigned to the person is "/film/film_story_contributor"?
>
>
> Thanks,
> Christian
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
More information about the Developers
mailing list