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