Question
I need all relations of one relation type, for example <RelationType>, but only where the related entities are of one entity type, such as Organization. relations/_scan returns relations, but I can't find a filter for the entity type of the start or end entity. Is there one?
Answer
No. relations/_scan and relations/_search filter only on the fields indexed for relations. These include the relation type, its attributes, and startObject and endObject, which hold entity IDs, not entity types. To filter on the entity type, use the Search Connections API instead. It first finds entities with an entity filter, then returns their relations of the types you list. {TenantURL} is https://<environment>.reltio.com/reltio/api/<tenantId>.
POST {TenantURL}/entities/_searchConnections?max=25&returnFullRelations=false&options=searchRelationsWithFilter
Authorization: Bearer <access_token>
Content-Type: application/json
{
"filter": "equals(type,'configuration/entityTypes/Organization')",
"connections": [
{
"outRelations": [ { "uri": "configuration/relationTypes/<RelationType>" } ]
}
]
}Reading the response
- The response has an
entitiesarray and arelationsarray. Each relation has itstype,startObjectandendObject. There's no option to leave outentities, so read only therelationsarray if that's all you need. outRelationsreturns relations where the found entity is the start object. If the entity is the end object of the relation, useinRelationsinstead.returnFullRelations=false, the default, returns only the relation type, start and end entity URIs, attributes, and crosswalks, which keeps the response small.maxlimits the entities found by the entity filter, not the connected entities. UseconnectedEntitiesMaxin the body to limit the connected entities returned for each entity.
Scanning all relations of one type
If you don't need the entity type, relations/_scan returns every relation of a type. Pass filter and max in the query string on the first request, for example POST {TenantURL}/relations/_scan?filter=(equals(relation_type,'<RelationType>'))&max=100. Then send the cursor from each response in the body of the next request.
Comments
Article is closed for comments.