Check a field contains string using script

I would like to run a query to check if a field is substring of a query string parameter. if yes , I want to return 1.
I am new to scripting and below code is not working.

Blockquote
GET testspan/_search
{
"size": 0,
"query": {
"match_all": {}
},
"aggs": {
"CONTAINS": {
"filter": {
"bool": {
"must": [
{
"term": {
"A": "10"
}
}
]
}
},
"aggs": {
"script_fields": {
"example": {
"script": {
"lang": "painless",
"source": """
if("CANADA POST VISA".contains(doc['SUSP_VAL'].value)){
return "1"
}
"""
}
}
}
}
}
}
}

thanks for the help

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