Amazon web services 如何在velocity模板(AWS appsync和elasticsearch)中使用字符串替换?
我正在编写一个appsync查询,以从elastic(使用velocity模板)按电话号码搜索记录 弹性体上存储的数据的格式为“0123456789”,但请求的格式可能为“012-123-1234”。所以我打算使用字符串替换函数来删除“-”字符。但是,我的代码返回以下错误:Amazon web services 如何在velocity模板(AWS appsync和elasticsearch)中使用字符串替换?,amazon-web-services,
elasticsearch,variadic-templates,aws-appsync,Amazon Web Services,
elasticsearch,Variadic Templates,Aws Appsync,我正在编写一个appsync查询,以从elastic(使用velocity模板)按电话号码搜索记录 弹性体上存储的数据的格式为“0123456789”,但请求的格式可能为“012-123-1234”。所以我打算使用字符串替换函数来删除“-”字符。但是,我的代码返回以下错误: "message": "Lexical error, Encountered: \" _ \ "(95), after: \". \ "at * unset * [line 11, column 51]" 我不确定我的书写
"message": "Lexical error, Encountered: \" _ \ "(95), after: \". \ "at * unset * [line 11, column 51]"
我不确定我的书写是否正确,请帮忙
这是我的代码:
{
"version":"2017-02-28",
"operation":"GET",
"path":"/res/res/_search",
"params":{
"headers":{},
"queryString":{},
"body":{
"from":$util.defaultIfNull($ctx.args.nextToken, 0),
"size":$util.defaultIfNull($ctx.args.limit, 20),
"query": {
"match": { "phoneNumber": "$context.args.phoneNumber".replace('-', '') }
}
}
}
}
嗯,我发现了错误,是“字符”的错误位置
"match": { "phoneNumber": "$context.args.phoneNumber".replace('-', '') }
"match": { "phoneNumber": "$context.args.phoneNumber.replace('-', '')" }
=>