# Pass result from first query to another one

**URL:** <https://discuss.elastic.co/t/pass-result-from-first-query-to-another-one/97681>\
**Category:** Elasticsearch\
**Created:** [August 20, 2017, 11:11am UTC](https://discuss.elastic.co/t/pass-result-from-first-query-to-another-one/97681 "2017-08-20T11:11:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![moabbas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/moabbas/32/19231_2.png) [@moabbas](https://discuss.elastic.co/u/moabbas)\
**Post date:** [August 20, 2017, 11:11am UTC](https://discuss.elastic.co/t/pass-result-from-first-query-to-another-one/97681/1 "2017-08-20T11:11:43Z")

</div>

> GET logstash-2017.08.14/gateway\_logs/\_search  
> {  
> "query": {  
> "bool": {  
> "must": {  
> "match": { "status": "logged in"}  
> }  
> }  
> }  
> }

The output is that:

> {  
> "\_index": "logstash-2017.08.14",  
> "\_type": "gateway\_logs",  
> "\_id": "AV3fVGuWRMNtmvyiarbS",  
> "\_score": 0.73761284,  
> "\_source": {  
> "@timestamp": "2017-08-14T06:00:38.031Z",  
> "login\_type": "Twitter",  
> "@version": "1",  
> "type": "gateway\_logs",  
> "stationIpAddress": "10.102.249.146",  
> "tags": [  
> "Success"  
> ],  
> "status": "logged in"  
> }  
> },

I need to pass the value of stationIpAddress in the second query

> GET logstash-2017.08.14/xms\_api\_station\_info/\_search  
> {  
> "query": {  
> "bool": {  
> "filter": {  
> "term": { "stationIpAddress": "i need to pass the value from result here"}  
> }  
> }  
> }  
> }

Thanks,

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [August 20, 2017, 5:28pm UTC](https://discuss.elastic.co/t/pass-result-from-first-query-to-another-one/97681/2 "2017-08-20T17:28:10Z")

</div>

Elasticsearch won't do that for you. You need to handle this externally. Maybe using a script or in an application.

---

<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:** [September 17, 2017, 5:28pm UTC](https://discuss.elastic.co/t/pass-result-from-first-query-to-another-one/97681/3 "2017-09-17T17:28:24Z")

</div>

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