# How to filter a results set AFTER 'collapse'?

**URL:** https://discuss.elastic.co/t/how-to-filter-a-results-set-after-collapse/92606
**Category:** Elasticsearch
**Created:** [July 11, 2017, 8:43am UTC](https://discuss.elastic.co/t/how-to-filter-a-results-set-after-collapse/92606 "2017-07-11T08:43:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Grigory\_Tukmachev](https://avatars.discourse-cdn.com/v4/letter/g/6bbea6/32.png) [@Grigory\_Tukmachev](https://discuss.elastic.co/u/Grigory_Tukmachev)
#### Post date: [July 11, 2017, 8:43am UTC](https://discuss.elastic.co/t/how-to-filter-a-results-set-after-collapse/92606/1 "2017-07-11T08:43:37Z")

</div>

Hello! I am really new in elasticsearch.  
Please, help me with the search requested build:

I push into an 'event' index records on every document status changes, and then, I want to find documents by CURRENT status (current - means, last reported)

I have the following fields in my 'my\_events' index: "obj\_id", "name", "type", "status", "status\_date"

I can obtain all my documents with 'current' status using 'collapse' approach:  
GET /my\_events/\_search  
{  
"collapse" : {  
"field" : "obj\_id"  
},  
"sort" : [{"status\_date" : {"order" : "desc"}}],  
"from": 0  
}  
this request will return by 1 record for every obj\_id with 'current' status.

but I need to FILTER this dataset to get, for example, all documents which current status equals, for example, to 'READY\_TO\_REVIEW'

Is it possible with Elasticsearch?

---

<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: [August 8, 2017, 8:43am UTC](https://discuss.elastic.co/t/how-to-filter-a-results-set-after-collapse/92606/2 "2017-08-08T08:43:38Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
