# \[elasticserach performance\] match query very slowly!

**URL:** https://discuss.elastic.co/t/elasticserach-performance-match-query-very-slowly/100743
**Category:** Elasticsearch
**Created:** [September 16, 2017, 2:38am UTC](https://discuss.elastic.co/t/elasticserach-performance-match-query-very-slowly/100743 "2017-09-16T02:38:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![laoyang360](https://avatars.discourse-cdn.com/v4/letter/l/a9a28c/32.png) [@laoyang360](https://discuss.elastic.co/u/laoyang360)
#### Post date: [September 16, 2017, 2:38am UTC](https://discuss.elastic.co/t/elasticserach-performance-match-query-very-slowly/100743/1 "2017-09-16T02:38:56Z")

</div>

1. Search the keyword "ladder" use matchQuery (java api) it will be very very very slowly!  
Time consuming as follows:

> {  
> "took": 7778,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 5,  
> "successful": 5,  
> "failed": 0  
> },  
> "hits": {  
> "total": 92,  
> "max\_score": 15.208916,

1. to do the matchquery full text search, the document is very large, the largest document about 2.5MB (return to the results)

2. Heap usage record, three nodes: 10% (master node), 4% (routing node), 58% (data node).

Want to analyze what causes it? And how to optimize the query?

----------------Dividing line-------------------------------- A  
The following is profile monitoring records.

> "profile": {  
> "shards": [  
> {  
> "id": "[BosI3A-bSJaVM0LHULDC9A] [baike\_index] [0]",  
> "searches": [  
> {  
> "query": [  
> {  
> "type": "TermQuery",  
> "description": "content: ladder"  
> "time": "0.5679210000ms",  
> "time\_in\_nanos": 567921,  
> "breakdown": {  
> "score": 4818,  
> "build\_scorer\_count": 23,  
> "match\_count": 0,  
> "create\_weight": 490622,  
> "next\_doc": 5347,  
> "match": 0,  
> "create\_weight\_count": 1,  
> "next\_doc\_count": 21,  
> "score\_count": 18,  
> "build\_scorer": 67071,  
> "advance": 0,  
> "advance\_count": 0  
> }  
> }  
> ],  
> "rewrite\_time": 379627,  
> "collector": [  
> {  
> "name": "CancellableCollector",  
> "reason": "search\_cancelled",  
> "time": "0.03252600000ms",  
> "time\_in\_nanos": 32526,  
> "children": [  
> {  
> "name": "SimpleTopScoreDocCollector",  
> "reason": "search\_top\_hits",  
> "time": "0.01902000000ms",  
> "time\_in\_nanos": 19020  
> }  
> ]  
> }  
> ]  
> }  
> ],  
> "aggregations":  
> },  
> {  
> "id": "[BosI3A-bSJaVM0LHULDC9A] [baike\_index] [1]",  
> "searches": [  
> {  
> "query": [  
> {  
> "type": "TermQuery",  
> "description": "content: ladder"  
> "time": "0.8072510000ms",  
> "time\_in\_nanos": 807251,  
> "breakdown": {  
> "score": 5896,  
> "build\_scorer\_count": 29,  
> "match\_count": 0,  
> "create\_weight": 745418,  
> "next\_doc": 7775,  
> "match": 0,  
> "create\_weight\_count": 1,  
> "next\_doc\_count": 16,  
> "score\_count": 13,  
> "build\_scorer": 48103,  
> "advance": 0,  
> "advance\_count": 0  
> }  
> }  
> ],  
> "rewrite\_time": 508630,  
> "collector": [  
> {  
> "name": "CancellableCollector",  
> "reason": "search\_cancelled",  
> "time": "0.04867000000ms",  
> "time\_in\_nanos": 48670,  
> "children": [  
> {  
> "name": "SimpleTopScoreDocCollector",  
> "reason": "search\_top\_hits",  
> "time": "0.02597900000ms",  
> "time\_in\_nanos": 25979  
> }  
> ]  
> }  
> ]  
> }  
> ],  
> "aggregations":  
> },  
> {  
> "id": "[BosI3A-bSJaVM0LHULDC9A] [baike\_index] [2]",  
> "searches": [  
> {  
> "query": [  
> {  
> "type": "TermQuery",  
> "description": "content: ladder"  
> "time": "0.8369420000ms",  
> "time\_in\_nanos": 836942,  
> "breakdown": {  
> "score": 8774,  
> "build\_scorer\_count": 31,  
> "match\_count": 0,  
> "create\_weight": 744262,  
> "next\_doc": 11751,  
> "match": 0,  
> "create\_weight\_count": 1,  
> "next\_doc\_count": 29,  
> "score\_count": 25,  
> "build\_scorer": 72069,  
> "advance": 0,  
> "advance\_count": 0  
> }  
> }  
> ],  
> "rewrite\_time": 458680,  
> "collector": [  
> {  
> "name": "CancellableCollector",  
> "reason": "search\_cancelled",  
> "time": "0.06351200000ms",  
> "time\_in\_nanos": 63512,  
> "children": [  
> {  
> "name": "SimpleTopScoreDocCollector",  
> "reason": "search\_top\_hits",  
> "time": "0.03681100000ms",  
> "time\_in\_nanos": 36811  
> }  
> ]  
> }  
> ]  
> }  
> ],  
> "aggregations":  
> },  
> {  
> "id": "[BosI3A-bSJaVM0LHULDC9A] [baike\_index] [4]",  
> "searches": [  
> {  
> "query": [  
> {  
> "type": "TermQuery",  
> "description": "content: ladder"  
> "time": "0.9213890000ms",  
> "time\_in\_nanos": 921389,  
> "breakdown": {  
> "score": 8899,  
> "build\_scorer\_count": 28,  
> "match\_count": 0,  
> "create\_weight": 745401,  
> "next\_doc": 11755,  
> "match": 0,  
> "create\_weight\_count": 1,  
> "next\_doc\_count": 29,  
> "score\_count": 22,  
> "build\_scorer": 155254,  
> "advance": 0,  
> "advance\_count": 0  
> }  
> }  
> ],  
> "rewrite\_time": 508615,  
> "collector": [  
> {  
> "name": "CancellableCollector",  
> "reason": "search\_cancelled",  
> "time": "0.07178900000ms",  
> "time\_in\_nanos": 71789,  
> "children": [  
> {  
> "name": "SimpleTopScoreDocCollector",  
> "reason": "search\_top\_hits",  
> "time": "0.04696100000ms",  
> "time\_in\_nanos": 46961  
> }  
> ]  
> }  
> ]  
> }  
> ],  
> "aggregations":  
> },  
> {  
> "id": "[DbUASJSzTDWaLQocTYuKpA] [baike\_index] [3]",  
> "searches": [  
> {  
> "query": [  
> {  
> "type": "TermQuery",  
> "description": "content: ladder"  
> "time": "0.3358920000ms",  
> "time\_in\_nanos": 335892,  
> "breakdown": {  
> "score": 6083,  
> "build\_scorer\_count": 26,  
> "match\_count": 0,  
> "create\_weight": 273080,  
> "next\_doc": 4956,  
> "match": 0,  
> "create\_weight\_count": 1,  
> "next\_doc\_count": 19,  
> "score\_count": 14,  
> "build\_scorer": 51713,  
> "advance": 0,  
> "advance\_count": 0  
> }  
> }  
> ],  
> "rewrite\_time": 265629,  
> "collector": [  
> {  
> "name": "CancellableCollector",  
> "reason": "search\_cancelled",  
> "time": "0.02894000000ms",  
> "time\_in\_nanos": 28940,  
> "children": [  
> {  
> "name": "SimpleTopScoreDocCollector",  
> "reason": "search\_top\_hits",  
> "time": "0.01789500000ms",  
> "time\_in\_nanos": 17895  
> }  
> ]  
> }  
> ]  
> }  
> ],  
> "aggregations":  
> }  
> ]  
> }  
> }

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [September 25, 2017, 8:40am UTC](https://discuss.elastic.co/t/elasticserach-performance-match-query-very-slowly/100743/2 "2017-09-25T08:40:22Z")

</div>

This is surprising indeed. The query is simple (TermQuery) and matches few documents. It should be very fast. Does it reproduce all the time?

---

<div class="post-metadata">

### Author: ![laoyang360](https://avatars.discourse-cdn.com/v4/letter/l/a9a28c/32.png) [@laoyang360](https://discuss.elastic.co/u/laoyang360)
#### Post date: [September 27, 2017, 8:10am UTC](https://discuss.elastic.co/t/elasticserach-performance-match-query-very-slowly/100743/3 "2017-09-27T08:10:44Z")

</div>

I already resolve it，because the document which i search is very very large and I use the plain method to highlight.  
When I change the fvh highlight, the bug is go away.  
Thanks!

---

<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: [October 25, 2017, 8:11am UTC](https://discuss.elastic.co/t/elasticserach-performance-match-query-very-slowly/100743/4 "2017-10-25T08:11:04Z")

</div>

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