# Elasticsearch slow query response time using terms facet

**URL:** https://discuss.elastic.co/t/elasticsearch-slow-query-response-time-using-terms-facet/14551
**Category:** Elasticsearch
**Created:** [November 22, 2013, 7:28pm UTC](https://discuss.elastic.co/t/elasticsearch-slow-query-response-time-using-terms-facet/14551 "2013-11-22T19:28:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![vinamar](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@vinamar](https://discuss.elastic.co/u/vinamar)
#### Post date: [November 22, 2013, 7:28pm UTC](https://discuss.elastic.co/t/elasticsearch-slow-query-response-time-using-terms-facet/14551/1 "2013-11-22T19:28:28Z")

</div>

We are experiencing unusual slow query response time using terms facets.  
With faceted search, the query takes around 15 to 20 secs to return the  
response.  
Without faceted search the query takes around 2 secs (still on the higher  
order of latency)  
Earlier With 11m documents and 3 data nodes and 2 non data nodes, the  
latency would be in the order of 100 to 200ms. Not sure whats going on  
here.

Couple of observations:  
a) The shards are not equally/fairly distributed among the 10 data nodes  
b) The master could be a data node or a non data node  
c) I thought adding more nodes would result in faster search response time  
(but i'm seeing decrease in performance of query execution) ?

Specs:  
Elasticsearch v0.90.2  
25 Million text documents indexed  
10 Data nodes (running on Centos 6)  
2 Non data nodes (running on Centos 6)  
running on JVM 7

Query issued:  
GET \_search  
{  
"facets": {  
"histo": {  
"date\_histogram": {  
"field": "closeDt",  
"interval": "1.5h"  
}  
},  
"channel": {  
"terms": {  
"field": "channel"  
}  
},  
"siteId": {  
"terms": {  
"field": "siteId"  
}  
}  
},  
"query": {  
"filtered": {  
"filter": [  
{  
"range": {  
"closeDt": {  
"from": 1325404800000,  
"to": 1385107200000  
}  
}  
}  
],  
"query": {  
"query\_string": {  
"query": "ebay now",  
"default\_operator": "AND",  
"fields": [  
[  
"emails.emailBody",  
"srId",  
"chatTextArray.text"  
]  
]  
}  
}  
}  
},  
"highlight": {  
"pre\_tags": [  
""  
],  
"post\_tags": [  
""  
],  
"fields": {  
"srId": {  
"number\_of\_fragments": 0  
},  
"emails.emailBody": {  
"number\_of\_fragments": 0  
},  
"chatTextArray.text": {  
"number\_of\_fragments": 0  
}  
}  
},  
"timeout": 30000  
}

Query response:  
{

- "took": 24426,\*  
"timed\_out": false,  
"\_shards": {  
"total": 16,  
"successful": 10,  
"failed": 6,  
"failures": [  
{  
"index": "\_river",  
"shard": 0,  
"status": 400,

Without facets - query response time is 2 secs (still the latency is high)  
{  
"took": 2625,  
"timed\_out": false,  
"\_shards": {  
"total": 16,  
"successful": 16,  
"failed": 0  
},  
"hits": {  
"total": 3942856,  
"max\_score": 0.30295128,  
"hits": [

Cluster health:  
{  
cluster\_name: elasticsearch\_dc1  
status: yellow  
timed\_out: false  
number\_of\_nodes: 12  
number\_of\_data\_nodes: 10  
active\_primary\_shards: 16  
active\_shards: 31  
relocating\_shards: 0  
initializing\_shards: 1  
unassigned\_shards: 0  
}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:05am UTC](https://discuss.elastic.co/t/elasticsearch-slow-query-response-time-using-terms-facet/14551/2 "2017-07-06T02:05:17Z")

</div>


