# HOW-TO: terms lookup or sth-else

**URL:** <https://discuss.elastic.co/t/how-to-terms-lookup-or-sth-else/37799>\
**Category:** Elasticsearch\
**Created:** [December 22, 2015, 10:09pm UTC](https://discuss.elastic.co/t/how-to-terms-lookup-or-sth-else/37799 "2015-12-22T22:09:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nskalis](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@nskalis](https://discuss.elastic.co/u/nskalis)\
**Post date:** [December 22, 2015, 10:09pm UTC](https://discuss.elastic.co/t/how-to-terms-lookup-or-sth-else/37799/1 "2015-12-22T22:09:58Z")

</div>

hi guys,

i am looking to cross-check two elastic search indices by comparing at least two keys  
the question is how can i query two indices and apply filtering on them ?  
for example

if i have an index called `index_1` with mapping

`{a1:"a1", b1:5, c1:"c"}`

also, i have another `index_2` with different mapping

`{a2:"a2", b2:8, c2:"c"}`

and i would like to retrieve the set of documents that

- c1 equals to c2
- b2 \> b1

could you please advise on how this can be accomplished ?

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [December 23, 2015, 5:54pm UTC](https://discuss.elastic.co/t/how-to-terms-lookup-or-sth-else/37799/2 "2015-12-23T17:54:46Z")

</div>

You cannot apply a join between two indices. You cannot even join two  
documents inside the same index without using parent/child relationships.

Ivan

---

<div class="post-metadata">

**Author:** ![nskalis](https://avatars.discourse-cdn.com/v4/letter/n/ebca7d/32.png) [@nskalis](https://discuss.elastic.co/u/nskalis)\
**Post date:** [December 23, 2015, 6:13pm UTC](https://discuss.elastic.co/t/how-to-terms-lookup-or-sth-else/37799/3 "2015-12-23T18:13:46Z")

</div>

thanks Ivan.  
[https://github.com/elastic/elasticsearch/issues/2674](https://github.com/elastic/elasticsearch/issues/2674) with terms lookup you can filter based on a value of a key that belongs to a different document of a different index, correct ?

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [December 23, 2015, 7:33pm UTC](https://discuss.elastic.co/t/how-to-terms-lookup-or-sth-else/37799/4 "2015-12-23T19:33:57Z")

</div>

The terms filter will not quite fulfill your requirements since your are  
looking to match on more than one field, plus you would need to provide an  
id for the document in the other index. You cannot match on arbitrary  
documents. Do you want to result to be both documents?

Ivan

---

<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 5, 2017, 11:29pm UTC](https://discuss.elastic.co/t/how-to-terms-lookup-or-sth-else/37799/5 "2017-07-05T23:29:01Z")

</div>


