☝️Small business or a startup? See if you qualify for our special offer.
+
All documentation
  • Introduction
  • Connecting to data source
    1. Supported data sources
    2. Connecting to other data sources
  • Browser compatibility
  • Documentation for older versions
  • Configuring the mapping

    This guide explains how to configure the mapping in Flexmonster when connecting to Elasticsearch. For example, you can customize field captions, date formats, time zones, field visibility, and more.

    Note Flexmonser mapping does not affect your mapping in Elasticsearch.

    Available properties

    The mapping in Flexmonster is described by the MappingObject, where each key is the field’s unique name, and the value is the FieldMappingObject. The FieldMappingObject for the Elastiсsearch data source contains the following properties:

    Property/TypeDescription
    caption
    String
    optional The field’s caption. Overrides the default name of the field.

    Live example

    aggregations
    String[]
    optional The list of aggregation functions that can be applied to the current measure.

    Live example

    filters
    Boolean
    optional Enables and disables the filter pop-up window for the field. When set to false, the filter pop-up window is disabled.
    Default value: true.
    visible
    Boolean
    optional When visible is set to false, the field is hidden from the Field List Live example.
    calendar_interval
    String
    optional Sets the Elasticsearch’s calendar_interval parameter for the date histogram. This parameter allows rounding down dates by the given interval. For example, if the calendar_interval is "day", 2021-05-25T19:30:00 will be rounded to 2021-05-25T00:00:00 Live example.
    See the list of supported intervals: Calendar intervals.
    Only for Elasticsearch version 7.2 and higher.
    Default value: "day".
    fixed_interval
    String
    optional Sets the Elasticsearch’s fixed_interval parameter for the date histogram. This parameter allows rounding down dates by the given interval. For example, if the fixed_interval is "3h", 2021-05-25T19:30:00 will be rounded to 2021-05-25T18:00:00 Live example.
    See the list of supported intervals: Fixed intervals.
    Only for Elasticsearch version 7.2 and higher.
    interval
    String
    optional Sets the Elasticsearch’s interval parameter for the date histogram. This parameter allows rounding down dates by the given interval. For example, if the interval is "day", 2021-05-25T19:30:00 will be rounded to 2021-05-25T00:00:00. Check out the list of supported intervals.
    Note that the interval was deprecated in Elasticsearch version 7.2 and removed in version 8. If your Elasticsearch version is higher than 7.2, use either calendar_interval or fixed_interval properties instead of the interval.
    time_zone
    String
    optional Used for the date histogram. You can specify time zones as either an ISO 8601 UTC offset (e.g., +01:00 or -08:00) or as a time zone ID as specified in the IANA time zone database, such as America/Los_Angeles. Check out this example.
    format
    String
    optional Used for the date histogram. Check out the supported date format/patterns.
    If options.datePattern is defined, the format will override its value for the field.
    min_doc_count
    Number
    optional 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).

    Example

    Check out an example of configured mapping for the Elasticsearch data source:

    dataSource: {
    type: "elasticsearch",
    node: "https://olap.flexmonster.com:9200",
    index: "australian_weather",
    mapping: {
    "Date": {
    caption: "Observation Date",
    format: "MMMM, yyyy",
    interval: "1M"
    },
    "Evaporation.keyword": {
    visible: false
    },
    "Location.keyword": {
    caption: "Weather Station Location"
    },
    "Max Temperature": {
    caption: "Max Temp",
    aggregations: [ "max" ]
    },
    }
    }

    Live example

    Formatting dates in Elasticsearch

    There are two ways to format dates in Elasticsearch: 

    • Using the options.datePattern property — this will apply formatting to all date fields in the dataset. 
    • Using the format property in the mapping — this will apply formatting to a certain field. If options.datePattern is defined, the format will override its value.

    options.datePattern

    When formatting dates with the options.datePattern property, use date patterns described in the Elasticsearch documentation.

    The following example demonstrates how to format dates using the options.datePattern:

    new Flexmonster({
      container: "pivotContainer",
      toolbar: true,
      report: {
        dataSource: {
          type: "elasticsearch",
          node: "https://olap.flexmonster.com:9200",
          index: "fm-product-sales"
        },   
        options: {
         datePattern: "dd MMMM, yyyy"
        }
      }
    });

    Live example

    format

    When formatting dates with the format property in the mapping, use date patterns described in the Elasticsearch documentation.

    The following example demonstrates how to format dates using the format:

    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"
    }
    }
    }
    }
    });

    Live example

    Formatting dates in the drill-through view

    Elasticsearch date patterns are fully applied to dates in the classic (tabular) and compact forms, while dates in the drill-through view may remain unformatted.

    If you need a date pattern that is applied in all the views similarly, format date fields using patterns supported in both Flexmonster and Elasticsearch:

    Expand the list of the date patterns
    • d – Day of the month. It is represented as a one or two-digit number. For example, 2 or 18.
    • dd – Day of the month. It is represented as a two-digit number. For example, 02 or 18.
    • M – Month. It is represented as a one or two-digit number. For example, 3 or 11.
    • MM – Month. It is represented as a two-digit number. For example, 03.
    • MMM – Month. It is represented as a three-letter abbreviation of the name of the month. For example, Mar.
    • MMMM – Month. It is represented as the full name of the month. For example, March.
    • yy – Year. It is represented as a two-digit number. For example, 16.
    • yyyy – Year. It is represented as a four-digit number. For example, 2016.
    • h – Hour of the day using the 12-hour format [1 – 12]. It is represented as a one or two-digit number. For example, 1 or 12.
    • hh – Hour of the day using the 12-hour format [1 – 12]. It is represented as a two-digit number. For example, 01 or 12.
    • H – Hour of the day using the 24-hour format [0 – 23]. It is represented as a one or two-digit number. For example, 0 or 23.
    • HH – Hour of the day using the 24-hour format [0 – 23]. It is represented as a two-digit number. For example, 00 or 23.
    • k – Hour of the day using the 24-hour format [1 – 24]. It is represented as a one or two-digit number. For example, 1 or 24.
    • kk – Hour of the day using the 24-hour format [1 – 24]. It is represented as a two-digit number. For example, 01 or 24.
    • m – Minutes [0 – 59]. It is represented as a one or two-digit number. For example, 0 or 59.
    • mm – Minutes [0 – 59]. It is represented as a two-digit number. For example, 00 or 59.
    • s – Seconds [0 – 59]. It is represented as a one or two-digit number. For example, 0 or 59.
    • ss – Seconds [0 – 59]. It is represented as a two-digit number. For example, 00 or 59.

    More examples

    To learn more about how to configure mapping for Elasticsearch, check out the following sections:

    See also