2015-10-06 77 views
1

索引ip時,我可能會遇到ipv6類型。盡我所能,在測繪,FOO(直到他們增加了對IPv6的支持),我試圖做這樣的事情:Elasticsearch對不匹配(錯誤)類型的默認行爲

"ip" : { 
     "type" : "string", 
     "index" : "not_analyzed", 
     "norms" : { 
       "enabled" : false 
     }, 
     "fields" : { 
      "ipV4" : { "type":"ip", "store":true} 
     } 
    } 

但我不把它所有的方式。我想是這樣的:

  1. 商店知識產權領域作爲一個字符串總是
  2. 如果一個IPv4字符串,存儲這樣的說法,但如果沒有,也不會引發錯誤和存儲默認值而不是。

我需要更改/添加什麼?

回答

1

這有助於回答我的問題:

Elasticsearch fails silently if document has mapping mismatch for a field

它使我的反應看起來更像是這樣的:

"ip" : { 
     "type" : "string", 
     "index" : "not_analyzed", 
     "norms" : { 
       "enabled" : false 
     }, 
     "fields" : { 
      "ipV4" : { 
       "type":"ip", 
       "store":true, 
       "ignore_malformed":true, 
       "null_value":"255.255.255.255" 
      } 
     } 
     } 

我要去標誌着這是正確的

+0

這工作像以前一樣嘗試意 – Ryan