to_ip.asciidoc 846 B

123456789101112131415161718192021222324252627282930
  1. [[esql-to_ip]]
  2. === `TO_IP`
  3. Converts an input string to an IP value.
  4. The input can be a single- or multi-valued field or an expression.
  5. Example:
  6. [source,esql]
  7. ----
  8. include::{esql-specs}/ip.csv-spec[tag=to_ip]
  9. ----
  10. which returns:
  11. [%header,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."`