You are viewing the documentation for Blueriq 17. Documentation for other versions is available in our documentation directory.
COLLECT FROM [WHERE]
Use this function to create a collection of entity or attribute instances (meeting certain criteria).
Syntax
COLLECT entity | attribute FROM collection [ WHERE ( expression ) ]
Inputs
- entity or attribute - Entity or attribute to collect.
- collection - A collection of entity instances.
- expression - Boolean expression that represents the criterion the instance has to meet.
Return type
- collection of entity instances
- collection of attribute values
A collections contains no duplicates. Intermediary COLLECT
expressions can contain duplicates however, please see the note on collections and duplicates.
Examples
Suppose the following model. Entity Teacher
has a multivalued relation with entity Child
via the relation Teacher.teaches_Children
.
Teacher instance | Child instance | Child.name | Child.hobbies |
---|---|---|---|
Teacher_1 | Child_1 | “Kim” | “Reading”, “Dancing” |
Teacher_1 | Child_2 | “Rick” | “Tennis”, “Dancing” |
Teacher_1 | Child_3 | “Bob” | “Painting”, “Basketball”, “Reading” |
Teacher_2 | Child_1 | “Kim” | “Reading”, “Dancing” |
Teacher_2 | Child_3 | “Bob” | “Painting”, “Basketball”, “Reading” |
Teacher_2 | Child_4 | “Mary” | “Football” |
Expression | Result | Type |
---|---|---|
COLLECT Child.name FROM ALL Child | [ “Kim”, “Rick”, “Bob”, “Mary” ] | String (multivalued) |
COLLECT Child FROM Teacher[Teacher_2].teaches_Children | [ Child_1, Child_3, Child_4 ] | Collection of Child instances |
COLLECT Child.hobbies FROM Teacher[Teacher_1].teaches_Children | [ “Reading”, “Dancing”, “Tennis”, “Painting”, “Basketball” ] | String (multivalued) |
COLLECT Child.name FROM ALL Child | [ “Kim”, “Bob” ] | String (multivalued) |
COLLECT Child.hobbies FROM ALL Child WHERE ( Child.name = "Mary" ) | [ “Football” ] | String (multivalued) |
Overview
Content Tools