Elastic search 7+爲什麼去掉了mapping type

Why are mapping types being removed?

Initially, we spoke about an “index” being similar to a “database” in an SQL database, and a “type” being equivalent to a “table”.

This was a bad analogy that led to incorrect assumptions. In an SQL database, tables are independent of each other. The columns in one table have no bearing on columns with the same name in another table. This is not the case for fields in a mapping type.

In an Elasticsearch index, fields that have the same name in different mapping types are backed by the same Lucene field internally. In other words, using the example above, the user_namefield in the user type is stored in exactly the same field as the user_name field in the tweet type, and both user_name fields must have the same mapping (definition) in both types.

This can lead to frustration when, for example, you want deleted to be a date field in one type and a boolean field in another type in the same index.

On top of that, storing different entities that have few or no fields in common in the same index leads to sparse data and interferes with Lucene’s ability to compress documents efficiently.

For these reasons, we have decided to remove the concept of mapping types from Elasticsearch.

【以上摘自官網原文】鏈接

主要意思有3點:

1、我們經常把二維數據庫與ES作類比的方式是不正確的假設。把“index”類比爲數據庫,“type”類比爲表。具體原因是,數據庫的表是物理獨立的,一個表的列跟另外一張表相同名稱的列沒有關係,而ES中並非如此,不同type映射類型中具有相同名稱的字段在內部由相同的Lucene字段支持。

2、當您想要索引一個deleted字段在不同的type中數據類型不一樣。一個類型中爲日期字段,另外一個類型中爲布爾字段時,這可能會導致ES的存儲失敗,因爲這影響了ES的初衷設計。

3、另外,在一個index中建立很多實體,type,沒有相同的字段,會導致數據稀疏,最終結果是干擾了Lucene有效壓縮文檔的能力,說白了就是影響ES的存儲、檢索效率。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章