By the 18th section

3) New version changes

ES7 and above removes the concept of type.

  • In a relational database, two data representations are independent even if they have columns with the same name, but this is not the case in ES. Elasticsearch is a search engine developed based on Lucene. Filed filed with the same name under different types in ES are ultimately processed in the same way in Lucene.
    • The two user_name of two different types are considered to be the same filed under the same index of ES. You must define the same filed mapping in two different types. Otherwise, the same field names in different types will conflict in processing, resulting in a decrease in Lucene processing efficiency.
    • The purpose of removing Type is to improve the data processing efficiency of ES.

Elasticsearch 7. X:

  • The type parameter in the URL is optional. For example, indexing a document no longer requires a document type.

Elasticsearch 8 x:

  • The TYPE parameter in the URL is no longer supported.

Solution: 1) Migrate the index from multiple types to single types, and each type of document has an independent index. 2) Migrate the type data under the existing index to the specified location. See Data Migration for details.

1. Create a mapping

Create the index and specify the mapping

PUT/my - index {" the mappings ": {/ / mapping rules" properties ": {" age" : {" type ":" integer "}, "email" : {" type ": "Name ": {"type": "text"}} "keyword",//keyword does not search for full text}}Copy the code

2. Add new field mappings

PUT /my-index/_mapping {"properties": {"employee-id": {"type": "keyword", "index": false// Index option Controls whether field values are indexed. It accepts true or false and defaults to true. Fields that are not indexed cannot be queried. }}}Copy the code

3. Update the mapping

We cannot update mapped fields that already exist. Updates must create new indexes for data migration

Refer to documentation – Mapping


Reference:

Elasticsearch Reference

elastic

Full text Search Engine Elasticsearch tutorial