Skip to content

replace - Replace a keypath

When we're cleaning up values, we often use the replace operator to overwrite the old field with a new one. replace will overwrite the value of an existing keypath with a new one.

Syntax

replace <keypath> with <expression>

Example - Decoding a URL encoded value

Consider the following document:

{
  "domain":"https://www.coralogix.com",
  "query_string":"a=b&b=c&c=d",
  "path": "/home",
  "query_string_parameters":{
    "name":"Tom%20Kosman",
    "b":"c",
    "c":"d"
  }
}

We can see that the parameter name is URL encoded. We can fix this using urlDecode and replace the keypath using the replace operator:

replace query_string_parameters.name with query_string_parameters.name.urlDecode()

This results in the following document:

{
  "domain":"https://www.coralogix.com",
  "query_string":"a=b&b=c&c=d",
  "path": "/home",
  "query_string_parameters":{
    "name":"Tom Kosman",
    "b":"c",
    "c":"d"
  }
}