# Rewrite\_time in \_search takes a lot longer after upgrading from 6.4.2 to 6.8.2

**URL:** <https://discuss.elastic.co/t/rewrite-time-in-search-takes-a-lot-longer-after-upgrading-from-6-4-2-to-6-8-2/196960>\
**Category:** Elasticsearch\
**Created:** [August 27, 2019, 1:56pm UTC](https://discuss.elastic.co/t/rewrite-time-in-search-takes-a-lot-longer-after-upgrading-from-6-4-2-to-6-8-2/196960 "2019-08-27T13:56:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![imrimt](https://avatars.discourse-cdn.com/v4/letter/i/76d3ee/32.png) [@imrimt](https://discuss.elastic.co/u/imrimt)\
**Post date:** [August 27, 2019, 1:56pm UTC](https://discuss.elastic.co/t/rewrite-time-in-search-takes-a-lot-longer-after-upgrading-from-6-4-2-to-6-8-2/196960/1 "2019-08-27T13:56:04Z")

</div>

We recently upgraded our ES cluster from 6.4.2 to 6.8.2 without any changes to the data. One thing we notice is that the _same_ search query takes a lot longer in 6.8.2, and after turning on profiling, we notice the significant time increase for `rewrite_time`. I couldn't find anything through the release notes that indicate this change in behavior.

Here's our query: [https://gist.github.com/imrimt/4bae846b627201de8dd0acf20f545cb7](https://gist.github.com/imrimt/4bae846b627201de8dd0acf20f545cb7)  
Here's the profiling section when running against the 6.4.2 cluster: [https://gist.github.com/imrimt/27fab2bf9bafa409ae34ae462c11cfc7](https://gist.github.com/imrimt/27fab2bf9bafa409ae34ae462c11cfc7)  
And here's the profiling section when running against the 6.8.2 cluster: [https://gist.github.com/imrimt/dba81fea4950d99ebbd6013c2d9e0b12](https://gist.github.com/imrimt/dba81fea4950d99ebbd6013c2d9e0b12)

If someone could take a look into this we would really appreciate it. Thanks in advance!

Updated: we were able to pin-point what was causing the increase in rewrite time -- it was the `field_value_factor` function in the `function_score` query within the `has_child` query. When we change this to `random_score`, the rewrite time significantly decreased to the speed we were seeing on 6.4.2. However, we still don't know why this is happening so would love some input from the ES team.

---

<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:** [September 24, 2019, 1:56pm UTC](https://discuss.elastic.co/t/rewrite-time-in-search-takes-a-lot-longer-after-upgrading-from-6-4-2-to-6-8-2/196960/2 "2019-09-24T13:56:06Z")

</div>

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