2017-04-27 117 views
1

例如,我想爲書籍和文件進行映射。這些書和文件具有共同的標題字段,但之後它們是不同的字段。所以,我製作了動態模板(使這種映射的主要原因是讓一些字符串字段設置爲關鍵字,而不是文本)。Elasticsearch - 動態字段模板映射

PUT my_index 
    { 
     "mappings" : { 
      "my_type" : { 
       "properties" : { 
        "title" : { 
         "type" : "keyword" 
        }, 
        "props" : { 
         "dynamic" : true, 
         "dynamic_templates": [ 
         { 
          "strings": { 
          "match_mapping_type": "string", 
          "mapping": { 
           "type": "keyword" 
          } 
          } 
         } 
         ] 
        } 
       } 
      } 
     } 
    } 

我是這樣做的,但錯誤與此相伴。

「原因」: 「失敗映射[my_type]解析:無類型 字段[道具]中指定的」,

的這個任何想法?

回答

2

動態模板類型的根看the link

你應該有水木清華這樣

{ 
    "mappings": { 
    "my_type": { 
     "properties": { 
     "title": { 
      "type": "keyword" 
     } 
     }, 
     "dynamic_templates": [ 
     { 
      "strings": { 
      "path_match": "props.*", 
      "match_mapping_type": "string", 
      "mapping": { 
       "type": "keyword" 
      } 
      } 
     } 
     ] 
    } 
    } 
} 
+0

它在場內效應「道具」? –

+0

@ J.Done您需要使用「path_match」:「道具。*」, –

+0

@ J.Done請參閱更新 –