Elasticsearch Reference "6.1" Mapping

Source: Internet
Author: User
Tags deprecated

 is a string as in catch-for dynamically Added fields.

Mapping is the process of defining how a document and the fields he contains are stored and indexed. For example, use mappings to define:

"Which strings should be treated as a whole, not split

"Which fields contain numbers, dates, or geographic information

Whether the field values in the document should be indexed to match all fields

The format of the date value

"Custom rules control the mapping of dynamically added fields

 


A mapping type has:1, Meta-fields Meta-fields was used to customize how a document ' s metadata associated was treated. Examples of Meta-fields include the document ' s _index, _type, _id, and _source fields.2, fields or properties A mapping Type contains a list of fields or properties pertinent to the Documen

Mapping type

Each index has a type of mapping that determines how he is indexed

Deprecated in "6.0.0", query deprecated mapping type

The types of mappings are:

1, the original domain: The original domain is used to define how to process the metadata in the document, the original domain includes the document index, the type, the _id field and the _source domain

2. Domain or attribute: The map type contains a list of document-related fields or attributes

 

field Datatypesediteach field have a data type which can be:1, a simple type like text, keyword, date,Long,Double, Boolean or IP.2, a type which supports the hierarchical nature of JSON such as Objector nested.
3, or a specialised type like Geo_point, Geo_shape, or completion.
It isOften useful to index the same fieldinchDifferent ways fordifferent purposes. For instance, a
stringField could be indexed asA text field forFull-text Search, and asa keyword field forsorting or
Aggregations. Alternatively, you could index astringfield with the standard Analyzer, the Chinese analyzer, and the French analyzer. this isThe purpose of Multi-fields. Most datatypes-Multi-fields via the fields parameter.

Data type of the domain

Each domain has a data type that functions as follows:

1, simple type such as text (the default word breaker also has a non-participle. keywork), keyword, date, long, double, Boolean, IP

2. Object or nested that supports JSON layered nature (nested entities can be searched independently)

3, there are more professional geo_point, Geo_shape, and completion type

For different purposes, it is often useful to index the same fields in different ways. For example, you can index a string field as a text field for a full-text search and as a key field for sorting or aggregation. Alternatively, you can index a string field using the standard parser, the English parser, and the French parser.

This is a multi-domain goal. Most data types support multiple fields through field parameters.

  

 Settings to prevent mappings Explosione
Defining Too many fieldsinchAn index isA condition that can leads to a mapping explosion, which can cause outof memory errors and
Difficult situations to recover from. This problem is more common than expected. As an example, consider a situationinchwhich everyNew
Document inserted introducesNewFields. This isQuite common withDynamicMappings. Every time a document containsNewFields, those'll end
UpinchThe index ' s mappings. This isn ' t worrying forA small amount of data, but it can become a problem asThe mapping grows. The following settings
Allow your to limit the number of field mappings that can be created manually or dynamically,inchorder to prevent bad documents fromCausing a mapping
Explosion

index.mapping.total_fields.limit
The maximum number of fields in an index. The default value is1000.
index.mapping.depth.limit
  
The maximum depth for a field, which is measured as the number of inner objects. For instance, if any fields is defined at the root object level,
Then the depth is1. If There is an object mapping, then the depth is2, etc. The default is20.
index.mapping.nested_fields.limit
  
The maximum number ofnestedIn a index, defaults to50. Indexing 1 document with nested fields actually indexes 101 documents as each
Nested document is indexed as a separate hidden document.

Prevent mapping explosions

Defining too many fields in the index causes the mapping to explode, which can lead to memory errors and difficult recovery scenarios. The problem may be more prevalent than expected. For example, consider a situation in which each new document that is inserted introduces a new field. This is very common in dynamic mapping. The mapping of the index is ended whenever the document contains a new field. This is not worrying for a small amount of data, but as the mapping grows, this can become a problem. The following settings allow you to limit the number of automatically or manually generated fiel to prevent mapping explosin from damaging the document:

Index.mapping.total_fields.limit: The maximum number of fields in the index. The default value is 1000

Index.mapping.depth.limit: The maximum depth of a field that is measured as the number of internal objects. For example, if all fields are defined at the root object level, then the depth is 1. If there is an object mapping, then the depth is 2, and so on. The default value is 20.

Index.mapping.nested_fields.limit: The maximum number of nested fields in the index, which defaults to 50. Indexing a document containing 100 nested fields actually indexes 101 documents, because each nested document is indexed as a separate hidden document.

Dynamic mappingeditfields and mapping types DoNot need to be defined before being used. Thanks toDynamicMappingNewField names would be added automatically, just by indexing a document. New fields can is added both to the top-level mapping type, and to innerObjectand nested fields. theDynamicMapping rules can configured to customise the mapping that isUsed for NewFields . Explicit mappingsedityou know more on your data than Elasticsearch can guess, so while DynamicMapping can useful toGetStarted, at some point you'll want to specify your ownExplicitmappings. You can create field mappings if you create an index, and you can add fields to an existing index with the PUT mapping A PI.
View Code

Dynamic mapping:

fields and map types do not need to be defined before they are used. Because of dynamic mapping, simply indexing a document will automatically add a new field name. You can add new fields to the top-level mapping type and to internal objects and nested fields.

Dynamic mapping rules can customize mappings for new fields.

Explicit mapping:

You know more about data than elasticsearch, so while dynamic mapping can be useful, in some cases you need to specify your own explicit mappings.

You can create a field map when you create an index, and you can use the put mapping API to add fields to an existing index.

where New Index with the correct mappings and reindex your data to that index.
View Code

Update existing field mappings

In addition to document records, existing field mappings cannot be updated, and changing the mappings will invalidate the original index. Instead, you should create a new index with the correct mapping to rebuild your index

Example Mappinga mapping could be specified when creating an index, asfollows: The map should be assigned a put my_index when the index is created {"Mappings": {    "Doc": {       "Properties": {         "title":    {"type":"text"  },         "name":     {"type":"text"  },         " Age":      {"type":"integer" },          "created":  {          "type":"Date",           "format":"strict_date_optional_time| | Epoch_millis"        }      }    }  }}
View Code

Elasticsearch Reference "6.1" 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.