-
Notifications
You must be signed in to change notification settings - Fork 35
Mapping Properties
In Unipop you map properties in schemas, by using schemas you can easily
map your existing data into a graph structure.
You can map properties in many different ways.
Maps a static value to a property.
Useful for providing some metadata about your source data store.
{
"properties":{
"someProperty": "some_value"
}
}
Maps a field from your data as a property in the graph.
It is recognized by starting with '@'.
{
"properties":{
"someProperty": "@some_field"
}
}
You can also add constraints to your property as including or excluding values.
{
"properties": {
"someProperty": {
"field": "some_field",
"excludes": ["some_value"],
"includes": ["some_other_value"]
}
}
}
You can combine several schemas to one property by concatenating the values.
{
"properties":{
"someProperty": {
"fields": ["some_value", "@some_field"],
"delimiter": "~"
}
}
}
And will generate a value like some_value~field_value
.
Specifying a delimiter is optional, the default delimiter is '_'.
You can combine several schemas into an array.
{
"properties": {
"someProperty": ["some_value", "@some_field"]
}
}
You can combine several schemas and provide only the first value returned.
{
"properties":{
"some_property": {
"type": "coalesce",
"fields": ["@some_field", "some_value"]
}
}
}
If 'some_field' has a value of 'value1' the 'some_property' value will be value1
.
If 'some_field' has a no value then the value of 'some_property' will be some_value
.
Maps a static value as a date.
{
"propeties":{
"some_property": {
"value": "2017-10-15T13:45:00",
"sourceFormat": "yyyy-MM-dd'T'HH:mm:ss",
"displayFormat": "yyyy-MM-dd HH:mm:ss:SSS"
}
}
}
This will allow us to have a single format for dates across different mappings.
Providing a display format is optional, the default value is 'yyyy-MM-dd HH:mm:ss:SSS'.
Maps a field from your data as a date in the graph.
{
"propeties":{
"some_property": {
"field": "some_field",
"sourceFormat": "yyyy-MM-dd'T'HH:mm:ss",
"displayFormat": "yyyy-MM-dd HH:mm:ss:SSS"
}
}
}
Providing a display format is optional, the default value is 'yyyy-MM-dd HH:mm:ss:SSS'.
Each provider can provide extra property schemas that are unique to the data store he utilizes.
As of this moment only elasticsearch has a provider property schema which is 'index property schema', it allows you to map an index as if it were a property and utilize many configurations. ie. multi indices for same mapping or even a field dependent index name (useful for daily indices and such).
{
"index": ["index1", "index2"]
}
{
"index":{
"default": "some_index_with_date~*",
"schema": {
"fields": ["some_index_with_date", "@date"],
"delimiter": "~"
}
}
}
The default index is used when no constraint is being put on the date property, if you don't provide a default index it
will use '*'.
You can also provide a pointer to other properties in the same mapping.
{
"index":{
"default": "some_index_with_date~*",
"schema": {
"fields": ["some_index_with_date", "$myDateProperty"],
"delimiter": "~"
}
},
"properties":{
"myDateProperty": "@date"
}
}