# Performance of has\_child query in large amounts of data

**URL:** <https://discuss.elastic.co/t/performance-of-has-child-query-in-large-amounts-of-data/115001>\
**Category:** Elasticsearch\
**Created:** [January 11, 2018, 5:03am UTC](https://discuss.elastic.co/t/performance-of-has-child-query-in-large-amounts-of-data/115001 "2018-01-11T05:03:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![9ian1i](https://avatars.discourse-cdn.com/v4/letter/9/34f0e0/32.png) [@9ian1i](https://discuss.elastic.co/u/9ian1i)\
**Post date:** [January 11, 2018, 5:03am UTC](https://discuss.elastic.co/t/performance-of-has-child-query-in-large-amounts-of-data/115001/1 "2018-01-11T05:03:03Z")

</div>

Hi everyone,  
I've had a very big problem recently. When I used the `has_child` query, it took a few minutes.  
Here is the detailed information:

About elasticsearch configuration:  
es version: **5.2.2**  
total documents： **100 billion**  
total data cost storage： **30 T**  
index number： **20 （search by alias）**  
shard number： **1700**  
node number： **15（each has 30G heap memory）**

About mappings:

```
**I have a parent type, it has one million documents** and each field like this:

"field_name": {
	"type": "text",
	"fields": {
		"keyword": {
			"type": "keyword",
			"ignore_above": 256
		}
	}
}

```

Then, I have about 20 child types, and each field like above one. But **the number of child document is very very very large** (100 billion minus number of parent type).  
So , when I query parent type like this, it will cost a few minutes:

```
{
  "query": {
	"constant_score": {
	  "filter": {
		"has_child": {
		  "child_type": "app_signature",
		  "query": {
			"constant_score": {
			  "filter": {
				"term": {
				  "app_signature_notafter.keyword": "Tue Dec 03 16:52:52 CST 2041"
				}
			  }
			}
		  }
		}
	  }
	}
  }
}

```

How can I improve query performance ? Add node or shard ? And is there a way to reduces query time to less than 10 seconds ?  
Thank you very much!

---

<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:** [February 8, 2018, 5:03am UTC](https://discuss.elastic.co/t/performance-of-has-child-query-in-large-amounts-of-data/115001/2 "2018-02-08T05:03:28Z")

</div>

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