# Filter aggregation vs Term aggregation with filtering values

**URL:** <https://discuss.elastic.co/t/filter-aggregation-vs-term-aggregation-with-filtering-values/21999>\
**Category:** Elasticsearch\
**Created:** [February 5, 2015, 9:07pm UTC](https://discuss.elastic.co/t/filter-aggregation-vs-term-aggregation-with-filtering-values/21999 "2015-02-05T21:07:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anant\_Aneja](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@Anant\_Aneja](https://discuss.elastic.co/u/Anant_Aneja)\
**Post date:** [February 5, 2015, 9:07pm UTC](https://discuss.elastic.co/t/filter-aggregation-vs-term-aggregation-with-filtering-values/21999/1 "2015-02-05T21:07:23Z")

</div>

I'm building aggregations on a field which has bot a '.analyzed' and a  
'.raw' version.  
The analyzer used is the standard analyzer

If I want to build filtered term buckets, what would be more performant

1. Using an 'include' specified on the terms aggregation on the '.raw'  
field (  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#\_filtering\_values](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#_filtering_values)  
)
2. Using a filter aggregation on the '.analyzed' version, then building the  
terms aggregation on the '.raw' field.

How will the performance change

1. If the field is really large
2. If the field is small (\< 300 characters)

I know that the semantics of querying on a analyzed field differs from a  
regex match; but if my users would be okay either way - what is the query  
which will have better perf on the cluster ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1597e450-c46f-4d98-9321-235768c03e2c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1597e450-c46f-4d98-9321-235768c03e2c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:34am UTC](https://discuss.elastic.co/t/filter-aggregation-vs-term-aggregation-with-filtering-values/21999/2 "2017-07-06T00:34:39Z")

</div>


