在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Java  Linux  網(wǎng)絡(luò)安全/ Elasticsearch相同index不同type下的相同字段怎么設(shè)置不同的類

Elasticsearch相同index不同type下的相同字段怎么設(shè)置不同的類型?

Elasticsearch創(chuàng)建mapping的時(shí)候發(fā)現(xiàn)不同type的相同字段名稱設(shè)置不同的type的是會(huì)報(bào)錯(cuò),所以請問一下這種情況應(yīng)該怎么解決???

請求連接

 PUT  http://localhost:9200/new

參數(shù)如下:

{
    "max_result_window": "1000000",
    "_source" : {
        "enabled": true
      },
      "_all" : {
        "enabled": false
      },
    "mappings": {
         "type1": {
          "properties": {
            "@timestamp" : {
              "type" : "date"
            },
            "@version" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "create_time" : {
              "index": "not_analyzed",
              "type" : "long"
            }
          }
        },
        "type2": {
          "properties": {
            "@timestamp" : {
              "type" : "date"
            },
            "@version" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "create_time" : {
              "index": "not_analyzed",
              "type" : "date"
            }
          }
        }
    }
}
 

請求結(jié)果:

 {
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "mapper [create_time] cannot be changed from type [date] to [long]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "mapper [create_time] cannot be changed from type [date] to [long]"
    },
    "status": 400
}
回答
編輯回答
鐧簞噯

可以使用嵌套對象,或者在子屬性設(shè)置成不同的那個(gè)類型,但是一旦設(shè)定了,也是不能變的

2017年2月19日 08:54
編輯回答
互擼娃

這個(gè)是Elasticsearch規(guī)定死的,同一個(gè)索引內(nèi)的相同字段必須是相同類型.

但是你可以曲線救國,利用copy_to,復(fù)制到另一個(gè)字段里,使用不同的類型

2017年1月26日 21:27