Configure the mapping for Elasticsearch

Mapping configuration

by Flexmonster Pivot Table

HTML

<script src="https://cdn.flexmonster.com/flexmonster.js"></script>

<div>
  <h2>How to configure the mapping for Elasticsearch</h2>
  <p>
    This example demonstrates how to configure the mapping for Elasticsearch
    fields.
  </p>
  <p>
    For the Elasticsearch data source, you can manage field captions,
    visibility, aggregations, and many more with the
    <code>dataSource.mapping</code> property.
  </p>
  <p>
    <a
      href="https://www.flexmonster.com/doc/configuring-the-mapping/"
      target="_blank"
    >Visit our docs to learn more about mapping properties supported for
    Elastisearch</a>.
  </p>
</div>

<div id="pivot-container"></div>

CSS

@import url(https://cdn.flexmonster.com/assets/jsfiddle-styles.css);

JavaScript

let pivot = new Flexmonster({
  container: "#pivot-container",
  componentFolder: "https://cdn.flexmonster.com/",
  width: "100%",
  height: 400,
  report: {
    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" ]
        },
        "Min Temperature": {
        	caption: "Min Temp",
          aggregations: [ "min" ]
        },
        "Rain Today.keyword": {
        	caption: "Rain Today"
        },
       	"Rain Tomorrow.keyword": {
        	caption: "Rain Tomorrow"
        },
        "Rainfall": {
        	caption: "Amount of Rainfall"
        },
        "State.keyword": {
        	filters: false
        },
       	"Sunshine.keyword": {
        	caption: "Sunshine Hours"
        },
        "Wind Speed": {
        	caption: "Average Wind Speed",
          aggregations: [ "average" ]
        },
      }
    },
    slice: {
    	rows: [
      	{ uniqueName: "State.keyword" },
        { uniqueName: "Location.keyword" }
      ],
      columns: [
      	{
       		uniqueName: "Date",
          filter: {
          	query: {
            	after: "2016-12-31"
            }
          }
        },
        { uniqueName: "[Measures]" }
      ],
      measures: [
      	{
        	uniqueName: "Min Temperature",
        	format: "-10ws2q1oviodoa"
      	},
      	{
        	uniqueName: "Max Temperature",
        	format: "-10ws2q1oviodoa"
      	},
      	{
        	uniqueName: "Wind Speed",
        	format: "-12d55123ugyhur"
      	}
    	]
   ...