2015-10-06 22 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