How can I select a test document which state has changed from "passed" to "failed"

I have test documents like one below:
test_reslulsts:
{
"report_id":"my_report_1",
"test_name":"some_test_name_123",
"status":"passed"
"parent_details":
{
"parent_id":"154865976079",
"run_tag":125
}
}

I need to select all the test_results that were passing for given "parent_id" and failing for another "parent_id".

I am using composite aggregation now, but it returns me only the tests whose status have changed.
I want to specify how the status was changed (for example from "passed" to "failed") and get all such documents not just their ids.

GET test_results/_search
{"query":
{"bool": {"must": [
{"terms": { "test_reslulsts.parent_id": ["154865976079","154881593370"]}}]
}},
"aggs" : {
"my_buckets": {
"composite" : { "size": 100,
"sources" : [
{ "test_name": { "terms" : { "field": "name" } } },
{ "test_result": { "terms" : { "field": "status" } } }
],
"after": {
"test_name": "some_test_name_1234",
"test_result": "failed"
}
},
"aggs": {
"filter": {
"bucket_selector": {
"buckets_path": {
"doc_count": "_count"
},
"script": "params.doc_count == 1"
}
}
}}
},
"size": 0
}

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