# Match search is slow, but I can't figure out the reason even using profile API

**URL:** https://discuss.elastic.co/t/match-search-is-slow-but-i-cant-figure-out-the-reason-even-using-profile-api/181100
**Category:** Elasticsearch
**Created:** [May 15, 2019, 6:36am UTC](https://discuss.elastic.co/t/match-search-is-slow-but-i-cant-figure-out-the-reason-even-using-profile-api/181100 "2019-05-15T06:36:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![traeyee](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@traeyee](https://discuss.elastic.co/u/traeyee)
#### Post date: [May 15, 2019, 6:36am UTC](https://discuss.elastic.co/t/match-search-is-slow-but-i-cant-figure-out-the-reason-even-using-profile-api/181100/1 "2019-05-15T06:36:41Z")

</div>

I'm using es 5.4 for searching purpose. But when I perform match query, I found that it costs hundreds of millisecond, which is unusual. I used the profile API to track the query and found that some words took unreasonable time. And I don't know what should I in the next.  
Here is the detailed info(I queried on 'ag2'):  
I establish a tow-node cluster, indices info:

```auto
yellow open test1 LQHj9rj-Ro6E6hRIutCU6Q 5 1 0 0 954b 795b
yellow open ag2_base qLZ1PpN0SBW6nXdMZOlpjg 5 1 1858557 0 21.9gb 21.9gb
yellow open ag1 U-9-JFY1SXSNLgdyB5iipA 5 1 366128 0 6.4gb 4.5gb
yellow open ag2 EcWa1psbQTGFQMXXEb7cxw 5 1 1858557 0 21.4gb 21.4gb
yellow open ag4 zYl27gx4SE6sxYWmKvhlbg 5 1 1858557 0 21.9gb 21.9gb

```

the query:

> curl -X GET localhost:9250/ag2/\_search?pretty=true -d '  
> {  
> "profile": true,  
> "query": {  
> "match": {"title": "cure fever"}  
> }  
> }  
> '

the weird part:

```auto
              {
                "type" : "TermQuery",
                "description" : "title:cure",
                "time" : "163.5755780ms",
                "time_in_nanos" : 163575578,
                "breakdown" : {
                  "score" : 72259602,
                  "build_scorer_count" : 19,
                  "match_count" : 0,
                  "create_weight" : 35370852,
                  "next_doc" : 55374841,
                  "match" : 0,
                  "create_weight_count" : 1,
                  "next_doc_count" : 71435,
                  "score_count" : 71416,
                  "build_scorer" : 427412,
                  "advance" : 0,
                  "advance_count" : 0
                }
              },
              {
                "type" : "TermQuery",
                "description" : "title:fever",
                "time" : "0.2344140000ms",
                "time_in_nanos" : 234414,
                "breakdown" : {
                  "score" : 0,
                  "build_scorer_count" : 19,
                  "match_count" : 0,
                  "create_weight" : 230746,
                  "next_doc" : 0,
                  "match" : 0,
                  "create_weight_count" : 1,
                  "next_doc_count" : 0,
                  "score_count" : 0,
                  "build_scorer" : 3648,
                  "advance" : 0,
                  "advance_count" : 0
                }

```

the mapping:

```auto
new_mappings = {
        "properties": {
            "did": {"type": "long", "index": "not_analyzed"},
            "title": {"type": "string", "index": "analyzed", "fielddata": {"loading": "eager"}},
            "title_embed": {"type": "double", "index": "no"},
            "entity": {"type": "string", "index": "not_analyzed", "fielddata": {"loading": "eager"}},
            "tag": {"type": "string", "index": "not_analyzed"},
            "aliases": {"type": "string", "index": "not_analyzed"},
            "entity_with_field": {"type": "string", "index": "not_analyzed", "fielddata": {"loading": "eager"}},
            "original_title": {"type": "string", "index": "analyzed", "analyzer": "standard", "fielddata": {"loading": "eager"}},
            "did3": {"type": "string", "index": "not_analyzed"},
            "title_entity": {"type": "string", "index": "not_analyzed", "fielddata": {"loading": "eager"}},
        }
    }

```

the 'cure' word took 160ms while 'fever' took less 1ms...

I'm new to es, so I don't know how to tune the es and cannot find out where the problem is, es configuration or system environment.  
I also want to know whether I can force to put some fields of particular index into memory so I can perform match query as fast as I can.

---

<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: [June 12, 2019, 6:46am UTC](https://discuss.elastic.co/t/match-search-is-slow-but-i-cant-figure-out-the-reason-even-using-profile-api/181100/2 "2019-06-12T06:46:25Z")

</div>

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