# Found in Full-text search scenario，ES 7 slow than ES 5

**URL:** https://discuss.elastic.co/t/found-in-full-text-search-scenario-es-7-slow-than-es-5/278065
**Category:** Elasticsearch
**Created:** [July 7, 2021, 12:06pm UTC](https://discuss.elastic.co/t/found-in-full-text-search-scenario-es-7-slow-than-es-5/278065 "2021-07-07T12:06:41Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![zfaster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zfaster/32/91284_2.png) [@zfaster](https://discuss.elastic.co/u/zfaster)
#### Post date: [July 7, 2021, 12:06pm UTC](https://discuss.elastic.co/t/found-in-full-text-search-scenario-es-7-slow-than-es-5/278065/1 "2021-07-07T12:06:41Z")

</div>

Planning to upgrade from ES 5.6.7 to ES7.X,；

During the test, the index data in ES5 was migrated to ES7, and performance comparison was performed in a specific scenario. **It was found that the search time of ES7 decreased severely with the increase of search word.**  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/a/4a8cf58524231787c7e2fc199416fac84baa0598.png)

cost time detail：  
ES5:

```auto
"score": 12630451,
"build_scorer_count": 63,
"match_count": 0,
"create_weight": 4035705,
"next_doc": 0,
"match": 0,
"create_weight_count": 1,
"next_doc_count": 0,
"score_count": 8332,
"build_scorer": 591863,
"advance": 36341745,
"advance_count": 54158

```

ES7:

```auto
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"set_min_competitive_score": 0,
"next_doc": 0,
"match": 0,
"next_doc_count": 0,
"score_count": 9276,
"compute_max_score_count": 0,
"compute_max_score": 0,
"advance": 31980019,
"advance_count": 42472,
"score": 74502869,
"build_scorer_count": 56,
"create_weight": 2902138,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 929773

```

ES5 version：5.6.7 jdk：1.8.0\_131  
ES7 version：7.7.1 jdk ：14.0.1  
The same amount of data, the same machine configuration

I want to know why in the scoring stage, ES7 takes several times longer than ES5. This is a problem with the design of ES7 itself, or because I didn't optimize it properly.  
Hope someone can help answer

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [July 7, 2021, 2:27pm UTC](https://discuss.elastic.co/t/found-in-full-text-search-scenario-es-7-slow-than-es-5/278065/2 "2021-07-07T14:27:58Z")

</div>

explaining your use-case, number of documents, your query and mapping might be helpful for others. This does not give any information for further debugging.

As apparently two use-cases got faster, that might be a problem with the query or mapping. Or it might be insufficient warmup, as you also need to explain your testing strategy...

---

<div class="post-metadata">

### Author: ![zfaster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zfaster/32/91284_2.png) [@zfaster](https://discuss.elastic.co/u/zfaster)
#### Post date: [July 8, 2021, 4:45am UTC](https://discuss.elastic.co/t/found-in-full-text-search-scenario-es-7-slow-than-es-5/278065/3 "2021-07-08T04:45:36Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/d/7/d72800ea778ffd2101f7462100f255ea00f12baf.png)  
In the three test scenarios, scoring time-consuming ES7 is generally slower. With the increase of search terms, the time-consuming is getting more and more serious. The reason why two scenarios are faster is because my search scenario contains part of the precise matching conditions. , ES7's performance improvement in precise matching results. As the search terms increase, the improvement brought by precise matching is not enough to make up for the time-consuming scoring, so it takes longer in the scenario of long search terms

---

<div class="post-metadata">

### Author: ![zfaster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zfaster/32/91284_2.png) [@zfaster](https://discuss.elastic.co/u/zfaster)
#### Post date: [July 8, 2021, 12:43pm UTC](https://discuss.elastic.co/t/found-in-full-text-search-scenario-es-7-slow-than-es-5/278065/4 "2021-07-08T12:43:58Z")

</div>

query like this demo

```auto
{
    "from": 0,
    "size": 21,
    "timeout": "3s",
    "query": {
        "bool": {

            "should": [
                {
                    "function_score": {
                        "query": {
                            "multi_match": {
                                "query": "部编人教版一年级语文下册11课彩虹的教案",
                                "fields": [
                                    "date^1.0",
                                    "issue^1.0",
                                    "body^3.0",
                                    "volume^1.1"
                                ],
                                "type": "best_fields",
                                "operator": "OR",
                                "slop": 0,
                                "prefix_length": 0,
                                "max_expansions": 50,
                                "lenient": false,
                                "zero_terms_query": "NONE",
                                "boost": 1.0
                            }
                        },
                        "functions": [
                            {
                                "filter": {
                                    "bool": {
                                        "must": [
                                            {
                                                "term": {
                                                    "name": {
                                                        "value": "BMC_Proc_2013_Jul_22_7(Suppl_3)_S1",
                                                        "boost": 1.0
                                                    }
                                                }
                                            },
                                            {
                                                "term": {
                                                    "accession": {
                                                        "value": "$SB0100",
                                                        "boost": 1.0
                                                    }
                                                }
                                            }
                                        ],
                                        "adjust_pure_negative": true,
                                        "boost": 1.0
                                    }
                                },
                                "weight": 5.0
                            }
                        ],
                        "score_mode": "sum",
                        "boost_mode": "sum",
                        "max_boost": 3.4028235e38,
                        "boost": 1.0
                    }
                },
                {
                    "constant_score": {
                        "filter": {
                            "match_phrase": {
                                "body": {
                                    "query": "部编人教版一年级语文下册11课彩虹的教案",
                                    "slop": 0,
                                    "boost": 1.0
                                }
                            }
                        },
                        "boost": 20.0
                    }
                }
            ],
            "adjust_pure_negative": true,
            "minimum_should_match": "1",
            "boost": 1.0
        }
    },

    "sort": [
        {
            "_score": {
                "order": "desc"
            }
        },
        {
            "timestamp": {
                "order": "desc"
            }
        }
    ]
}

```

---

<div class="post-metadata">

### Author: ![zfaster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zfaster/32/91284_2.png) [@zfaster](https://discuss.elastic.co/u/zfaster)
#### Post date: [July 16, 2021, 11:00am UTC](https://discuss.elastic.co/t/found-in-full-text-search-scenario-es-7-slow-than-es-5/278065/5 "2021-07-16T11:00:53Z")

</div>

I found the problem. The performance of ES7 is lower than that of ES5 in executing the function\_score method. If you simply execute multi\_match ES7, the performance will be better, but I don’t know why the performance of function\_score ES7 is lower. It is found through the profile that the function\_score related classes have changed. ES5-\>FiltersFunctionScoreQuery  
ES7-\>FunctionScoreQuery, so does anyone know the reason for the slowness

---

<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: [August 13, 2021, 11:01am UTC](https://discuss.elastic.co/t/found-in-full-text-search-scenario-es-7-slow-than-es-5/278065/6 "2021-08-13T11:01:46Z")

</div>

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