Filter vs nested type

I have a filter and I have a nested type that essentially gets the same
result. What's the primary difference and which one is better?

"query" : {
"nested" : {
"path" : "attributes",
"score_mode" : "avg",
"query" : {
"bool" : {
"must" : [
{
"text" : {"attributes.name" : "age"}
},
{
"text" : {"attributes.value" : "1"}
}
]
}
}
}
}

{
"query" : {
"filtered" : {
"query" : {
"term" : { "name" : "age" }
},
"filter" : {
"and" : [
{
"range" : {
"value" : {
"from" : "1",
"to" : "1"
}
}
}
]
}
}
}
}