# Get Hierarchical Data...Pls Helppp!

**URL:** <https://discuss.elastic.co/t/get-hierarchical-data-pls-helppp/193419>\
**Category:** Elasticsearch\
**Created:** [August 1, 2019, 10:37pm UTC](https://discuss.elastic.co/t/get-hierarchical-data-pls-helppp/193419 "2019-08-01T22:37:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bidzina\_Goginashvili](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bidzina_goginashvili/32/51114_2.png) [@Bidzina\_Goginashvili](https://discuss.elastic.co/u/Bidzina_Goginashvili)\
**Post date:** [August 1, 2019, 10:37pm UTC](https://discuss.elastic.co/t/get-hierarchical-data-pls-helppp/193419/1 "2019-08-01T22:37:23Z")

</div>

I have a little problem with Elasticsearch...  
I have products table.which looks something like this  
ID NAME MODELNAME IsParentModel  
1 IPhone 7 16 gb IPhone 7 1  
2 IPhone 7 32 gb IPhone 7 0  
3 IPhone 7 64 gb IPhone 7 0  
4 IPhone X 16 gb IPhone X 1  
5 IPhone X 32 gb IPhone X 0  
6 IPhone X 64 gb IPhone X 0  
what i am trying to do is to get ParentProducts and then get all child products with same modelname, but problem is that i can't get more than (declared size) products.I Was trying to get Parent Modeled Products with first query and than get child queries but it is not returning all the child modeled products because by defauld it has size 10 and i don't know what to do.  
I am developing Elasticsearch on .net.This is what it looks like...

This query returns parentproducts...

> var response = searchDescriptor.Size(50)  
> .Index("products")  
> .Query(q =\> q  
> .Terms(c =\> c  
> .Field("categories.id")  
> .Terms(categoryIds)))  
> .Query(z =\> z  
> .Bool(b =\> b  
> .Should(  
> sh =\> sh  
> .Term(tt =\> tt.IsParent, true))));

Get ReturnedProducts ModelNames

> var sameModeledIds = \_client.Search(searchDescriptor)  
> .Hits.Select(x =\> x.Source.ModelName).ToList();

And than i have Method to get all the children samemodelnamedProducts

> var modelNamedProductIds = FilteredModelNames(sameModeledIds);

For returning childrens Method Looks Like this...

> private int[\*] FilteredModelNames(IList modelIds)  
> {  
> var ressp = searchDescriptor  
> .Size(I dont need size i need to select all mathed data :((()  
> .Index("onoff-products-tests-main")  
> .Query(q =\>  
> q.Terms(c =\>  
> c.Field(x =\> x.ModelName.Suffix("keyword")).Terms(modelIds)))  
> .Query(z =\>  
> z.Bool(b =\>  
> b.Should(sh =\> sh.Term(tt =\> tt.IsParent, false))));
> 
> var resp = \_client.Search(searchDescriptor)  
> .Hits.Select(x =\> int.Parse(x.Id)).ToArray();
> 
> ```
> return resp; }
> 
> ```

---

<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:** [August 29, 2019, 10:49pm UTC](https://discuss.elastic.co/t/get-hierarchical-data-pls-helppp/193419/2 "2019-08-29T22:49:35Z")

</div>

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