Logstash Elasticsearch filer query to filter data from existing data

Also I this in template.json
{
"query":{
"bool": {
"should": [
{
"match": {
"id": "%{[id]}"
}
}
]
}
}
}

but getting an error like

Ruby exception occurred: undefined local variable or method `null' for #LogStash::Filters::Ruby:0x4aadbb56 {:class=>"NameError",