Cannot cast def [java.lang.String] to boolean

Dear All,

I am simply trying to update documents using ingest pipeline with below script. But facing subjected error. Please suggest....

{
"script": {
"lang": "painless",
"source": """
if(ctx.customer_gender = "MALE")
{
ctx.customer_gender = "male"
}
else
{
ctx.customer_gender = "female"
}
"""
}
}

Hi @Sourabh_Korde

try:

if(ctx.customer_gender == "MALE")

Worked out, thank you.

"script": {
"lang": "painless",
"source": """
if(ctx.customer_gender == "MALE")
{
ctx.customer_gender = "m"
}
else
{
ctx.customer_gender = "f"
}
"""
}

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.