# How To search on all the Ids in a Index in TermLookUp Mechanism

**URL:** <https://discuss.elastic.co/t/how-to-search-on-all-the-ids-in-a-index-in-termlookup-mechanism/243658>\
**Category:** Elasticsearch\
**Created:** [August 4, 2020, 7:23am UTC](https://discuss.elastic.co/t/how-to-search-on-all-the-ids-in-a-index-in-termlookup-mechanism/243658 "2020-08-04T07:23:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kashifa](https://avatars.discourse-cdn.com/v4/letter/k/4af34b/32.png) [@kashifa](https://discuss.elastic.co/u/kashifa)\
**Post date:** [August 4, 2020, 7:23am UTC](https://discuss.elastic.co/t/how-to-search-on-all-the-ids-in-a-index-in-termlookup-mechanism/243658/1 "2020-08-04T07:23:14Z")

</div>

I have two indices namely "School" and "Student" and I have to join these two indices based on some criteria and populate the results. Let me state the example scenario here.  
School Data Example:  
`{ "resourceType" : "School", "id" : "example", "active" : true, "name" : [{ "use" : "official", "family" : "AMS" }] }`  
Student Example  
`{ "resourceType" : "Student", "id" : "child_example", "active" : true, "name" : [{ "use" : "official", "family" : "Peter", "given" : [ "Peter", "James"] } ], "subject" : { "reference" : "AMS" } }`

Term LookUp mechanism Query:  
GET : [http://localhost:9200/student/\_search](http://localhost:9200/student/_search)  
`{ "query" : { "terms" : { "subject.reference.keyword" : { "index" : "school", "type" : "School", "id" : "nJNJuHMBODG38ZFrBfoV", "path" : "name.family" } } } }`

Here,I am able to lookup only with one Id,I have a requirement to search all Ids on the Index and bring all the student records of the school (AMS). Also I wanted to join all student records with the school record which has a parent-child relationship.  
I,e Consider there are 50 records in school and 100 records in student. I want to match all the students studying in AMS school and aggregate those students and school record as a result.

Please advice me here, how can I achieve this.

---

<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 1, 2020, 7:23am UTC](https://discuss.elastic.co/t/how-to-search-on-all-the-ids-in-a-index-in-termlookup-mechanism/243658/2 "2020-09-01T07:23:14Z")

</div>

Closed on September 1, 2020, 7:23am UTC

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