When elasticsearch type to create the type of attention the project, the latest elasticsearch has not recommended an index at multiple type

https://www.elastic.co/guide/cn/elasticsearch/guide/current/mapping.html
If there are two different types, each type has a field of the same name, but different mapping (example: a string a is a number), what would happen?
The answer is simple, Elasticsearch will not allow you to define the mapping. When you configure this mapping, there will be an exception.
Detailed answer is all fields in each Lucene index contains a single, flat pattern. Can be mapped to a particular field may be a string type number type, but not both. Because the type is better than the additional Lucene mechanism (in the form of metadata _type field) elasticsearch added, all types of elasticsearch ultimately share the same mapping.
In both types of index data mapping example:

{
   "data": {
      "mappings": {
         "people": {
            "properties": {
               "name": {
                  "type": "string",
               },
               "address": {
                  "type": "string"
               }
            }
         },
         "transactions": {
            "properties": {
               "timestamp": {
                  "type": "date",
                  "format": "strict_date_optional_time"
               },
               "message": {
                  "type": "string"
               }
            }
         }
      }
   }
}

Each type defines two fields (namely, "name" / "address" and the "timestamp" / "message"). They appear to be independent of each other, but in the background Lucene to create a map, such as:

{
   "data": {
      "mappings": {
        "_type": {
          "type": "string",
          "index": "not_analyzed"
        },
        "name": {
          "type": "string"
        }
        "address": {
          "type": "string"
        }
        "timestamp": {
          "type": "long"
        }
        "message": {
          "type": "string"
        }
      }
   }
}

Note: This is not a real and effective mapping syntax, just for demonstration
for the entire index, was flat maps into a single, global patterns in nature. That's why you can not define two types of conflict fields: When the mapping is flattened, Lucene does not know how to handle.

Conclusion
Technically, a plurality of types may be present in the same index, as long as they do not conflict fields (either because the fields are mutually exclusive mode, or because they share the same field).
The important point is: the same type can distinguish a very good collection of different segments. The data in different segments of the overall pattern is the same (or similar).
Type is not suitable for completely different types of data. If the two types of fields sets are different from each other, which means that half of the data in the index is empty (the field will be sparse), will eventually lead to performance problems. In this case, it is preferred to use two separate indices.


In Elaticsearch 6.x versions have only allowed the next index is only one type, multiple type declaration has been marked as expired, but still can be used. After version 7.0 will be completely removed
https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html

Guess you like

Origin www.cnblogs.com/gavinYang/p/11200212.html