This tutorial explains how to define a mapping object for an Elasticsearch index in a report and what settings this mapping object supports.
A mapping
object can have the following properties:
caption
(optional) – String. Overrides the default name of the field.visible
(optional) – Boolean. When set to false
, hides the field from the Field List. interval
(optional) – String. Used for the date histogram. Check out the supported time units. time_zone
(optional) – String. Used for the date histogram. You can specify timezones as either an ISO 8601 UTC offset (e.g. +01:00
or -08:00)
or as a timezone ID as specified in the IANA timezone database, such as `America/Los_Angeles`. Check out this example.format
(optional) – String. Used for the date histogram. Check out the date format/pattern. min_doc_count
(optional) – Number. Used for the date histogram. Can be used to show intervals with empty values (min_doc_count: 0
). Default value: 1
(empty intervals are hidden).All unnecessary fields can be hidden by setting "visible": false
:
var pivot = new Flexmonster({
container: "pivotContainer",
toolbar: true,
report: {
"dataSource": {
"type": "elasticsearch",
/* the host for the connection */
"node": "https://olap.flexmonster.com:9200",
/* the name of Elasticsearch index to connect */
"index": "fm-product-sales",
/* additional setting to configure index mapping */
},
"mapping": {
"@timestamp": {
"visible": false
},
"@version": {
"visible": false
},
"host": {
"visible": false
},
"message": {
"visible": false
},
"path": {
"visible": false
}
}
}
});
Check out the example on JSFiddle.
The following example demonstrates how to format dates:
new Flexmonster({
container: "pivotContainer",
toolbar: true,
report: {
dataSource: {
type: "elasticsearch",
node: "https://olap.flexmonster.com:9200",
index: "fm-product-sales",
},
mapping: {
"@timestamp": {
"format": "dd/MM/yyyy"
}
},
slice: {
rows: [{
"uniqueName": "@timestamp"
}],
columns: [{
"uniqueName": "[Measures]"
}],
measures: [{
"uniqueName": "Price",
"aggregation": "sum"
}]
}
}
});
Check out the example on JSFiddle.