# Elastic Search Hierarchical Data Need Helpp

**URL:** <https://discuss.elastic.co/t/elastic-search-hierarchical-data-need-helpp/193466>\
**Category:** Elasticsearch\
**Created:** [August 2, 2019, 7:22am UTC](https://discuss.elastic.co/t/elastic-search-hierarchical-data-need-helpp/193466 "2019-08-02T07:22:35Z")\
**Posts on this page:** 4\
**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 2, 2019, 7:22am UTC](https://discuss.elastic.co/t/elastic-search-hierarchical-data-need-helpp/193466/1 "2019-08-02T07:22:35Z")

</div>

I have a little problem with elastic search...  
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 elastic search on .net.This is what it looks like...

**this query returns parentproducts...**

```auto
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**

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

```

**and than i have Method to get all the children samemodelnamedProducts**

```auto
var modelNamedProductIds = FilteredModelNames(sameModeledIds);

```

**For returning childrens Method Looks Like this...**

```auto
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, true))
        )
    );
       
 var resp = _client.Search<ElasticProductOverviewModel>(searchDescriptor)
            .Hits.Select(x => int.Parse(x.Id)).ToArray();

return resp;

```

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [August 4, 2019, 11:38pm UTC](https://discuss.elastic.co/t/elastic-search-hierarchical-data-need-helpp/193466/2 "2019-08-04T23:38:15Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel to be able to see what your question looks like. I've formatted your question this time, but please take the time to format it properly in the future.

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [August 4, 2019, 11:40pm UTC](https://discuss.elastic.co/t/elastic-search-hierarchical-data-need-helpp/193466/3 "2019-08-04T23:40:15Z")

</div>

Can you please provide the index mappings, and some data and C# POCOs/types to work with?

---

<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, 2019, 11:40pm UTC](https://discuss.elastic.co/t/elastic-search-hierarchical-data-need-helpp/193466/4 "2019-09-01T23:40:22Z")

</div>

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