# Multi-field collapsing

**URL:** <https://discuss.elastic.co/t/multi-field-collapsing/19532>\
**Category:** Elasticsearch\
**Created:** [August 29, 2014, 4:03pm UTC](https://discuss.elastic.co/t/multi-field-collapsing/19532 "2014-08-29T16:03:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Hudson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brian_hudson/32/1306_2.png) [@Brian\_Hudson](https://discuss.elastic.co/u/Brian_Hudson)\
**Post date:** [August 29, 2014, 4:03pm UTC](https://discuss.elastic.co/t/multi-field-collapsing/19532/1 "2014-08-29T16:03:07Z")

</div>

I have a use case which requires collapsing on multiple fields.

As a simple example assume I have some movie documents indexed with the  
fields: Director, Actor, Title & Release Date. I want to be able to  
collapse on Director and Actor, getting the most recent movie (as indicated  
by Release Date).

I think the new top hits aggregation almost gets me mostly what I need. I  
can create a terms aggregation on Director, with a sub terms aggregation on  
Actor, and add a top hits aggregation to that (size 1). Would this be the  
proper approach? By traversing over the aggregations I can get all of the  
hits that I want - however I can't (have elasticsearch) sort or page them.

It's almost like I'd need a "hitCollector" aggregation which would collect  
all search hits generated by it's sub aggregations and allow me to specify  
sort and paging information at that level. Thoughts?

Brian

--  
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/318b7474-004f-4244-90e8-d9b93639481f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/318b7474-004f-4244-90e8-d9b93639481f%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, 1:05am UTC](https://discuss.elastic.co/t/multi-field-collapsing/19532/2 "2017-07-06T01:05:28Z")

</div>


