Sightglass Data Filter Ontology¶
Sightglass users pull data from a Cloud-based database which contains a copy of data published from within Aunsight. Because that database contains all data prepared for a solution, it may sometimes be helpful to deploy data filters to make sure individual users see only the data that is relevant and necessary to them. In some cases, data filters may be necessary to ensure compliance with data privacy and security rules. To that end, Aunsight provides the ability to control the delivery of data to Sightglass users by defining filters using a JSON data ontology.
This article describes the Sightglass data source filter ontology and shows how to construct filters in valid JSON form. To deploy a filter for a particular user, most Sightglass administrators will want to use the Sightglass admin feature in the Web interface to deploy these filters for specific users. However, it is important to understand this data ontology and how to describe it using JSON in order to use this feature.
Basic Syntax¶
Sightglass filters are defined using an object ontology expressed in JSON notation. More specifically, filters are defined as properties of the data_source_filters
object, which contains properties named for the solution's data sources whose values are arrays of filter objects.
The data_source_filters
Property¶
The data_source_filters
property allows the user to define filters for a Sightglass member.
Filters are defined by adding the name of a data source defined in the Sightglass solution as a property of data_source_filters
.
Each of these JSON names will have an array of expression objects as its value.
"data_source_filters": {
"first_data_source": [...],
"second_data_source": [...],
"third_data_source": [...]
}
Data Filter Expression Objects¶
Filter objects are added to the data source name as elements in an array.
There are three basic parts of a data source filter object:
field
- The name of the field in the named data source.op
- The expression operator to be used (see below)value
- The value to use in evaluating the expression.
The following is an example of a list of expressions for a data source named "companies":
"data_source_filters": {
"companies": [
{
"field": "industry_sector",
"op": "in",
"value": ["finance", "healthcare," "telecom"]
},
{
"field": "country",
"op": "eq",
"value": "Germany"
},
{
"field": "price",
"op": "lte",
"value": "200"
}
]
}
Tip
Because Javascript does not require object properties to be ordered, these properties can be defined in any order.
The preceding JSON will produce a member filter that will display data from the companies
data source where the following conditions are all met:
- The 'industry_sector' field has the value "finance," "healthcare," or "telecom."
- The 'country' field has "Germany" as its exact value.
- The 'price' field is less than or equal to 200.
Expression Operators¶
The Sightglass filter objects employs an operator property (the op
property), whose value refers to a specific type of logical operator. The following reference describes Aunsight's operators and their use.
eq¶
The eq
(equals) operator returns all records where the value of a specified field is equal to value
.
Note
Multiple eq
operators can be used on different fields to further refine the results, but using this operator on the same field more than once will always yield zero results. This is because filter expressions are combined using an AND comparison. To select records where a field matches one of several values, see the [in](#in)
operator.
{
"field": "country",
"op": "eq",
"value": "Germany"
},
{
"field": "industry_sector",
"op": "eq",
"value": "finance"
}
Will filter for records where the country
field is exactly equal to "Germany" and the industry_sector
is equal to "finance." All other records will be excluded.
ne¶
The ne
(not equal to) operator returns all records where the value of field
is not equal to the specified value. Logically, this is the opposite of eq.
{
"field": "classification",
"op": "ne",
"value": "top secret"
},
This filter will return all records except those where the classification
field is not equal to "top secret."
in¶
The in
(item in array) operator filters records where the value
is present in any item in a specified array. This operation provides a way to filter records where a specified field matches one of several values.
{
"field": "country",
"op": "in",
"value": ["Germany", "France," "Japan"]
}
This filter will return all records where the country
field equals "Germany," "France," or "Japan."
nin (Does not match item in array)¶
The nin
(item not in array) operator filters records where the value
is not present in any item in a specified array. This operation provides a way to filter records where a specified field matches one of several values. In that sense, it is the equivalent of multiple ne
operators on the same field.
{
"field": "classification",
"op": "ne",
"value": ["top secret", "sensitive"]
},
This filter will return all records except those where the classification
field is not equal to "top secret" or "sensitive."
startswith¶
The startswith
operator filters records where the value
begins with or is exactly the substring specified in "value."
Note
This filter only applies to fields of the String
data type.
{
"field": "country",
"op": "startswith",
"value": "United"
}
This filter will return all records where the country
field starts with "United," such as "United States," "United Kingdom," and "United Arab Emirates."
lt¶
The lt
(less than) and lte
(less than or equal to) operators filter records where the numerical value of field
is less than, or less than or equal to the specified value
.
Note
This operator only applies to fields with a numerical data type.
{
"field": "price",
"op": "lt",
"value": "200"
}
This filter will return all records where the price field is 199 or lower. If the lte
operator is substituted, this will filter records whose price is 200 or lower.
gt¶
The gt
(greater than) and gte
(greater than or equal to) operators filter records where the numerical value of field
is greater than, or greater than or equal to the specified value
.
Note
This operator only applies to fields with a numerical data type.
{
"field": "price",
"op": "gt",
"value": "200"
}
This filter will return all records where the price field is 201 or greater. If the lte
operator is substituted, this will filter records whose price is 200 or greater.