Creating relationships with the connect directive

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 second one is useful when you are populating values for multiple types for an instance.

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 want to programatically find the ECT of a property, use this query:

{
"query" : {
"expected_type" : {
"id" : null,
"name" : null
},
"id" : "/film/film/story_by",
"type" : "/type/property"
}
}

Search Help Center

Discussions

There are no conversations on this topic. Would you like to start one?

Start the Discussion »