How to query again with query results?

My data sample is like this. Key-value log

"Clientip”: “10.1.1.1” “downstreamid”:10 “upstreamid”: 1
..
..
"Clientip”: “10.2.1.1” “downstreamid”:1 “upstreamid”: 22
..
..
"Clientip”: “10.3.1.1” “downstreamid”:22 “upstreamid”: 44
..
..

From above sample, pseudo code are :

select clientip, downstreamid, upstreamid from index_name where downstreamid=10
Print clientip, downstreamid, upstreamid
key = upstreamid

Select clientip, downstreamid, upstreamid from index_name where downstream=key
Print clientip, downstreamid, upstreamid
key = upstreamid

Select clientip, downstreamid, upstreamid from index_name where downstream=key
Print clientip, downstreamid, upstreamid

I’d like to query again with result of previous query. Is it possible to query using one Elasticsearch DSL query ? If not possible, please recommend other idea.

Eventually, I want to use this query on Kibana.

You need your code to do this, it's nothing ES or KB can do for you.