elasticsearch 6.0.0及之後移除了一個索引允許映射多個類型的操作(Removal of mapping types)

來源:互聯網
上載者:User

標籤:查詢   說明   href   cas   prim   arc   文檔   for   ova   

用到了6.2,還以為像5.X 一樣允許建立 父-子關係文檔 ,即一個索引下允許映射多個類型,操作後發現行不通

如下代碼:

PUT /company{  "mappings": {    "branch": {},    "employee": {      "_parent": {        "type": "branch"       }    }  }}

 

找到最新的官方文檔,給出了說明,大意是:

6.0.0移除了一個索引允許映射多個類型,雖然還支援同索引多類型查詢,但是Elasticsearch 7.0.0的版本將完全放棄。

 

不過官方給了另外的方案解決

Custom type fieldeditOf course, there is a limit to how many primary shards can exist in a cluster so you may not want to waste an entire shard for a collection of only a few thousand documents. In this case, you can implement your own custom type field which will work in a similar way to the old _type.Let’s take the user/tweet example above. Originally, the workflow would have looked something like this:PUT twitter{  "mappings": {    "user": {      "properties": {        "name": { "type": "text" },        "user_name": { "type": "keyword" },        "email": { "type": "keyword" }      }    },    "tweet": {      "properties": {        "content": { "type": "text" },        "user_name": { "type": "keyword" },        "tweeted_at": { "type": "date" }      }    }  }}PUT twitter/user/kimchy{  "name": "Shay Banon",  "user_name": "kimchy",  "email": "[email protected]"}PUT twitter/tweet/1{  "user_name": "kimchy",  "tweeted_at": "2017-10-24T09:00:00Z",  "content": "Types are going away"}GET twitter/tweet/_search{  "query": {    "match": {      "user_name": "kimchy"    }  }}You could achieve the same thing by adding a custom type field as follows:PUT twitter{  "mappings": {    "_doc": {      "properties": {        "type": { "type": "keyword" },         "name": { "type": "text" },        "user_name": { "type": "keyword" },        "email": { "type": "keyword" },        "content": { "type": "text" },        "tweeted_at": { "type": "date" }      }    }  }}PUT twitter/_doc/user-kimchy{  "type": "user",   "name": "Shay Banon",  "user_name": "kimchy",  "email": "[email protected]"}PUT twitter/_doc/tweet-1{  "type": "tweet",   "user_name": "kimchy",  "tweeted_at": "2017-10-24T09:00:00Z",  "content": "Types are going away"}GET twitter/_search{  "query": {    "bool": {      "must": {        "match": {          "user_name": "kimchy"        }      },      "filter": {        "match": {          "type": "tweet"         }      }    }  }}   The explicit type field takes the place of the implicit _type field.

  這是官網的6.x的關於此點的描述:https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html

elasticsearch 6.0.0及之後移除了一個索引允許映射多個類型的操作(Removal of mapping types)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.