Close ES dynamic Create mapping

Source: Internet
Author: User

Using the default configuration of ES will cause us to automatically create a field when the index does not exist in mapping.

This will undoubtedly bring us trouble.

When we don't want a field to be searched, we can start dynamically creating mapping.

Perform the following actions:

put/test_xzy/_mapping/data{  "dynamic": false}

Then view mapping:

Get/test_xzy/_mappings/data

Get:

{"Test_xzy": {"mappings": {"    data": {        "dynamic": "false",        "Properties": {            "age": {" Type ":" "Long"          },          "hate": {            "type": "String"          }, "like          ": {            "type": "String"          },          "Name": {            "type": "String"}}}}}  

In this way, fields that do not exist in mapping will not be present in mapping after being indexed, and such fields cannot be used for searching.

We're tighter. Data that can be set for fields that are not in mapping cannot be written to es:

put/test_xzy/_mapping/data{  "dynamic": "Strict"}

Then we get the following error when we write other field data that is not "name,age,like,hate":

Mapping set to strict, dynamic introduction of [Hatae] within [data] was not allowed

Close ES dynamic Create mapping

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.