What are the differences between "filter" and "filtered"?

Hi all,

I'm a newbie in Elastic Search. I got a question subject while researching
ES "What are the differences between "filter" and "filtered" ?
I tried creating 2 queries and running them to see if there was any
difference in the result but there wasn't. Could some body please help
pointing out the differences of those 2 filters?

Filtered

{
"query":{
"filtered":{
"query":{
"term" : { "_type" : "item" }
},
"filter":{
"range" : {
"price" : { "to" : 1 }
}
}
}
}
}

Filter

{
"query":{
"term" : { "_type" : "item" }
},
"filter" : {
"range" : {
"price" : { "to" : 1 }
}
}
}

Regards,

Ngoc Vo

Hi Ngoc,

the difference is in how facets are counted -- with filtered, facets
are counted from results after filtering (=smaller counts). filter
will count facets from the query results before filtering = greater
numbers.

It's also mentioned in the docs: Elasticsearch Platform — Find real-time answers at scale | Elastic

Best,
Radim

On Jun 27, 10:50 am, Ngoc Vo ngoc.vo3...@gmail.com wrote:

Hi all,

I'm a newbie in Elastic Search. I got a question subject while researching
ES "What are the differences between "filter" and "filtered" ?
I tried creating 2 queries and running them to see if there was any
difference in the result but there wasn't. Could some body please help
pointing out the differences of those 2 filters?

Filtered

{
"query":{
"filtered":{
"query":{
"term" : { "_type" : "item" }},

"filter":{
"range" : {
"price" : { "to" : 1 }}
}
}
}
}

=========================

Filter

{
"query":{
"term" : { "_type" : "item" }},

"filter" : {
"range" : {
"price" : { "to" : 1 }}
}
}

=========================

Regards,

Ngoc Vo

Hi Radim,

Thank you for your patience in explaining the differences between those two
filters. I really appreciate your help.

Regards,
Ngoc Vo

Vào 19:22:23 UTC+7 Thứ tư, ngày 27 tháng sáu năm 2012, Radim đã viết:

Hi Ngoc,

the difference is in how facets are counted -- with filtered, facets
are counted from results after filtering (=smaller counts). filter
will count facets from the query results before filtering = greater
numbers.

It's also mentioned in the docs:
Elasticsearch Platform — Find real-time answers at scale | Elastic

Best,
Radim

On Jun 27, 10:50 am, Ngoc Vo ngoc.vo3...@gmail.com wrote:

Hi all,

I'm a newbie in Elastic Search. I got a question subject while
researching
ES "What are the differences between "filter" and "filtered" ?
I tried creating 2 queries and running them to see if there was any
difference in the result but there wasn't. Could some body please help
pointing out the differences of those 2 filters?

Filtered

{
"query":{
"filtered":{
"query":{
"term" : { "_type" : "item" }},

"filter":{
"range" : {
"price" : { "to" : 1 }}
}
}
}
}

=========================

Filter

{
"query":{
"term" : { "_type" : "item" }},

"filter" : {
"range" : {
"price" : { "to" : 1 }}
}
}

=========================

Regards,

Ngoc Vo