All Implemented Interfaces:
NamedWriteable, Writeable, Resolvable, EvaluatorMapper, OptionalArgument, ConvertFunction, SurrogateExpression

Converts strings to IPs.

IPv4 addresses have traditionally parsed quads with leading zeros in three mutually exclusive ways:

  • As octal numbers. So 1.1.010.1 becomes 1.1.8.1.
  • As decimal numbers. So 1.1.010.1 becomes 1.1.10.1.
  • Rejects them entirely. So 1.1.010.1 becomes null with a warning.

These three ways of handling leading zeros are available with the optional leading_zeros named parameter. Set to octal, decimal, or reject. If not sent this defaults to reject which has been Elasticsearch's traditional way of handling leading zeros for years.

This doesn't extend from AbstractConvertFunction so that it can support a named parameter for the leading zeros behavior. Instead, it rewrites itself into either ToIpLeadingZerosOctal, ToIpLeadingZerosDecimal, or ToIpLeadingZerosRejected which are all AbstractConvertFunction subclasses. This keeps the conversion code happy while still allowing us to expose a single method to users.