# Matching specific mget query items to result

**URL:** <https://discuss.elastic.co/t/matching-specific-mget-query-items-to-result/6180>\
**Category:** Elasticsearch\
**Created:** [December 16, 2011, 10:06pm UTC](https://discuss.elastic.co/t/matching-specific-mget-query-items-to-result/6180 "2011-12-16T22:06:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josh](https://avatars.discourse-cdn.com/v4/letter/j/45deac/32.png) [@Josh](https://discuss.elastic.co/u/Josh)\
**Post date:** [December 16, 2011, 10:06pm UTC](https://discuss.elastic.co/t/matching-specific-mget-query-items-to-result/6180/1 "2011-12-16T22:06:59Z")

</div>

We are currently using ES as our search layer on top of our RDBMS.  
The RDBMS conducts a sub-optimal many-to-many join based on matching  
id's in two tables (say, Table 1 and Table 2), then the joined  
Table1+Table2 results are put into ES for indexing. Table 1 has id,  
and "result", and Table 2 has id and "result" - with the "result"  
being a numeric value that we need to compare between the tables.  
Users generally upload several hundred id's and "results" to Table 1  
in bulk, and then need to compare those uploaded values to Table 2 in  
NRT. Table 2 is only updated daily.

We were contemplating how we might use ES's (ridiculously) fast  
searching to make the join rather than beat up our RDBMS because the  
RDBMS join isn't really scaling that well. I've read on other posts  
in the group that many-to-many is tricky, but can be done, e.g.:  
[https://groups.google.com/group/elasticsearch/browse\_thread/thread/e61ffcb0421eb654/3793d2420e5f65e8?lnk=gst&q=many-to-many#3793d2420e5f65e8](https://groups.google.com/group/elasticsearch/browse_thread/thread/e61ffcb0421eb654/3793d2420e5f65e8?lnk=gst&q=many-to-many#3793d2420e5f65e8)

So here's the question:

Has anybody tried something like the following?:

1. Place Table 1 id's and results from the RDBMS into a Multi Get  
request
2. Obtain, from the search results, matching Table 2 id's that are  
already indexed in ES
3. Also return with each Table 2 id and "result" that is found, the  
matching Table 1 id and "result" that was submitted in the Multi Get  
request.

Item 3 is what we're struggling with. The idea would be to "pass  
through" the query parameter (in this case, id & "result" from Table

1. to the result set with the specific id and "result" from Table 2  
that it matches to -- thus creating a joined result set that could be  
indexed into ES.

Are we crazy?

Many thanks in advance for your thoughts.

---

<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:** [July 6, 2017, 3:45am UTC](https://discuss.elastic.co/t/matching-specific-mget-query-items-to-result/6180/2 "2017-07-06T03:45:04Z")

</div>


