to_ip.asciidoc 871 B

12345678910111213141516171819202122232425262728
  1. [discrete]
  2. [[esql-to_ip]]
  3. === `TO_IP`
  4. Converts an input string to an IP value.
  5. The input can be a single- or multi-valued field or an expression.
  6. Example:
  7. [source.merge.styled,esql]
  8. ----
  9. include::{esql-specs}/ip.csv-spec[tag=to_ip]
  10. ----
  11. [%header.monospaced.styled,format=dsv,separator=|]
  12. |===
  13. include::{esql-specs}/ip.csv-spec[tag=to_ip-result]
  14. |===
  15. Note that in the example above the last conversion of the string isn't
  16. possible. When this happens, the result is a *null* value. In this case a
  17. _Warning_ header is added to the response. The header will provide information
  18. on the source of the failure:
  19. `"Line 1:68: evaluation of [TO_IP(str2)] failed, treating result as null. Only first 20 failures recorded."`
  20. A following header will contain the failure reason and the offending value:
  21. `"java.lang.IllegalArgumentException: 'foo' is not an IP string literal."`