Featured resource
Forrester Wave Report 2025
Pluralsight named a Leader in the Forrester Wave™

Our tech skill development platform earned the highest scores possible across 11 criteria.

Learn more
  • Labs icon Lab
  • Cloud
Labs

Define Mappings in Elasticsearch

Dynamic templates in Elasticsearch make it very easy to index data without having to create explicit mappings for every field. However, sometimes you might prefer to create explicit mappings, or even disable dynamic mapping altogether, in order to have a tighter control over your index structure and datatype requirements. In this learning activity, you are given the opportunity to create explicit field mappings for an index containing log data. Specifically, you will exercise how to: * Create analyzed string fields with a specific analyzer * Create non-analyzed string fields with character limits * Create `geo_point` field mappings * Create numerical field mappings * Create date field mappings * Create IP field mappings * Create nest field mappings (objects) * Reindex data from one index into another with different mappings

Labs

Path Info

Level
Clock icon Advanced
Duration
Clock icon 2h 0m
Published
Clock icon Jan 10, 2020

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Create the index with explicit field mappings.

    Use the Kibana console tool to execute the following:

    PUT logs_new
    {
      "mappings": {
        "properties": {
          "@message": {
            "type": "text"
          },
          "@tags": {
            "type": "keyword",
            "ignore_above": 128
          },
          "@timestamp": {
            "type": "date"
          },
          "@version": {
            "type": "keyword",
            "ignore_above": 256
          },
          "agent": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "bytes": {
            "type": "long"
          },
          "clientip": {
            "type": "ip"
          },
          "extension": {
            "type": "keyword",
            "ignore_above": 256
          },
          "geo": {
            "properties": {
              "coordinates": {
                "type": "geo_point"
              },
              "dest": {
                "type": "keyword",
                "ignore_above": 128
              },
              "src": {
                "type": "keyword",
                "ignore_above": 128
              },
              "srcdest": {
                "type": "keyword",
                "ignore_above": 128
              }
            }
          },
          "headings": {
            "type": "keyword",
            "ignore_above": 256
          },
          "host": {
            "type": "keyword",
            "ignore_above": 256
          },
          "ip": {
            "type": "ip"
          },
          "links": {
            "type": "keyword",
            "ignore_above": 256
          },
          "machine": {
            "properties": {
              "os": {
                "type": "keyword",
                "ignore_above": 256
              },
              "ram": {
                "type": "long"
              }
            }
          },
          "memory": {
            "type": "long"
          },
          "phpmemory": {
            "type": "long"
          },
          "referrer": {
            "type": "keyword",
            "ignore_above": 256
          },
          "relatedContent": {
            "properties": {
              "article:modified_time": {
                "type": "date"
              },
              "article:published_time": {
                "type": "date"
              },
              "article:section": {
                "type": "keyword",
                "ignore_above": 128
              },
              "article:tag": {
                "type": "keyword",
                "ignore_above": 128
              },
              "og:description": {
                "type": "text"
              },
              "og:image": {
                "type": "keyword",
                "ignore_above": 256
              },
              "og:image:height": {
                "type": "long"
              },
              "og:image:width": {
                "type": "long"
              },
              "og:site_name": {
                "type": "keyword",
                "ignore_above": 256
              },
              "og:title": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "og:type": {
                "type": "keyword",
                "ignore_above": 128
              },
              "og:url": {
                "type": "text",
                "analyzer": "simple",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              },
              "twitter:card": {
                "type": "keyword",
                "ignore_above": 128
              },
              "twitter:description": {
                "type": "text"
              },
              "twitter:image": {
                "type": "keyword",
                "ignore_above": 256
              },
              "twitter:site": {
                "type": "keyword",
                "ignore_above": 128
              },
              "twitter:title": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 128
                  }
                }
              },
              "url": {
                "type": "text",
                "analyzer": "simple",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
                }
              }
            }
          },
          "request": {
            "type": "text",
            "analyzer": "simple",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "response": {
            "type": "keyword",
            "ignore_above": 128
          },
          "spaces": {
            "type": "text",
            "analyzer": "whitespace"
          },
          "url": {
            "type": "text",
            "analyzer": "simple",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "utc_time": {
            "type": "date"
          },
          "xss": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 512
              }
            }
          }
        }
      },
      "settings": {
        "number_of_shards": 4,
        "number_of_replicas": 3
      }
    }
    
  2. Challenge

    Reindex the documents from the logs index into the logs_new index.

    Use the Kibana console tool to execute the following:

    POST _reindex
    {
      "source": {
        "index": "logs"
      },
      "dest": {
        "index": "logs_new"
      }
    }
    

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.