# Parsing query array within a query

**URL:** <https://discuss.elastic.co/t/parsing-query-array-within-a-query/118936>\
**Category:** Elasticsearch\
**Created:** [February 7, 2018, 10:32pm UTC](https://discuss.elastic.co/t/parsing-query-array-within-a-query/118936 "2018-02-07T22:32:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickds](https://avatars.discourse-cdn.com/v4/letter/n/c2a13f/32.png) [@nickds](https://discuss.elastic.co/u/nickds)\
**Post date:** [February 7, 2018, 10:32pm UTC](https://discuss.elastic.co/t/parsing-query-array-within-a-query/118936/1 "2018-02-07T22:32:24Z")

</div>

Hi,

I'm currently using Elasticsearch 6.1.1, and I'm a little curious to see if there's a better method for what I'm currently doing.

So I've got two separate indexes (a-\* and b-_). a-_ has a column (eg col1) which will have identical values in colA in b-\*. I need to pull up a list of values from colB in a-\* which have matching colA values with a specified col1 value from b-\*. The only col1 values in mind are values associated with a single col2 value (eg all entries where col2 = "target"). A diagram of this system can be seen below:

 ![Blank%20Diagram%20-%20Page%201](https://us1.discourse-cdn.com/elastic/original/3X/a/d/adfadcb825f3b36029389c7e40571a7a935ce2f2.png)

The thing is, these values are typically ingested at the exact same time, so there's no way to specify a parent-child relationship at the ingestion point from Logstash. Moreover, there can be multiple colA values for each colB value.

I've currently got a system running through Python where Python uses the ES API to find all entries in a-\* where col2 is identical to a certain value (eg "target"), and extract all col1 values as a list. Python then uses this list of col1 values to perform a second query on b-\* where colA values match any item in the list.

So my question is; is there a way to perform some small query within a query to rule out the middle man? So a query on b-\* where colA matches the results of another query on a-\*?

Thanks!

---

<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:** [March 7, 2018, 10:32pm UTC](https://discuss.elastic.co/t/parsing-query-array-within-a-query/118936/2 "2018-03-07T22:32:27Z")

</div>

Closed on March 7, 2018, 10:32pm UTC

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