Required properties are object type properties that must have a value. You can use this object type property to validate that there are no objects that have a null value for this property, or an empty array if it is an array property. This validation applies to data from the backing datasource and edits via actions.
When working with required properties, keep the following in mind:
Note that if there is any null value currently set on the backing column for the property, the reindex will fail. To fix this, you must either update the backing datasource to no longer have nulls in the column, or unset the property as required.
You may occasionally encounter situations where null values appear in required properties of object types backed by multiple datasources. This phenomenon occurs when a record for the object is present in some datasources, but absent in the datasource that supplies the required property.
The following example illustrates this behavior. Assume there is a Movie
object type with two backing datasources and a Genre
property that is required.
Datasource 1
Movie Id | Title | Box office | Regions |
---|---|---|---|
101 | The Adventure Begins | 200m | ["USA", "Canada", "UK"] |
102 | Love in the City | 75m | [] |
103 | Galactic Battles | 500m | ["USA", "UK", "Australia"] |
Datasource 2
Movie Id | Budget | Genre (Required) | Director |
---|---|---|---|
101 | 50m | Adventure | Michael John Smith |
102 | 20m | Romance | Jane Doe |
103 | 150m | Sci-Fi |
If a new Movie
is added to both backing datasources without providing a value for Genre
, it will fail to index to the Ontology.
However, suppose only Datasource 1 had a row for the new Movie
object.
Datasource 1
Movie Id | Title | Box office | Regions |
---|---|---|---|
101 | The Adventure Begins | 200m | ["USA", "Canada", "UK"] |
102 | Love in the City | 75m | [] |
103 | Galactic Battles | 500m | ["USA", "UK", "Australia"] |
104 | Happy Ending | 150m | ["UK", "FRANCE"] |
Datasource 2
Movie Id | Budget | Genre (Required) | Director |
---|---|---|---|
101 | 50m | Adventure | Michael John Smith |
102 | 20m | Romance | Jane Doe |
103 | 150m | Sci-Fi |
The example above will successfully get indexed into the Ontology, despite the fact that the resulting object would have no value for the required property.
Property | Value |
---|---|
Movie Id | 104 |
Title | Happy Ending |
Box Office | 150m |
Regions | ["UK", "FRANCE"] |
Budget | |
Genre (Required) | |
Director |
The same applies to objects created via Action edits. Movie
objects can be created or modified successfully, if they only contain properties tied to columns in Datasource 1
. However if the Action adds a property to the object that is sourced from Datasource 2
, such as Budget
, then the Action will be invalid and will fail to execute. This is because the object will now be present on Datasource 2
and thus Genre
must be set.