# Prevent Elasticsearch re-index on update by query

**URL:** <https://discuss.elastic.co/t/prevent-elasticsearch-re-index-on-update-by-query/113446>\
**Category:** Elasticsearch\
**Created:** [December 28, 2017, 12:53pm UTC](https://discuss.elastic.co/t/prevent-elasticsearch-re-index-on-update-by-query/113446 "2017-12-28T12:53:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adriano](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@Adriano](https://discuss.elastic.co/u/Adriano)\
**Post date:** [December 28, 2017, 12:53pm UTC](https://discuss.elastic.co/t/prevent-elasticsearch-re-index-on-update-by-query/113446/1 "2017-12-28T12:53:53Z")

</div>

I am using Elasticsearch 5 with Nest 5 on C#.

I have an entity like this:

```
public class Visitor {
...
    public List<ESRecipient> RecipientOf { get; set; }
...

```

A mapping like this

```
.Index(ESIndexName)	
.Settings(s => s
	...
	.RefreshInterval("10s")
	...
)
.Mappings(m => m
	.Map<Visitor>(map => map

		// Routing required
		.AutoMap().RoutingField(r => r.Required(true))
		
		// Custom Properties
		...
		.Properties(p => p.Nested<ESRecipient>(n => n.Name(name => name.RecipientOf).AutoMap()))
        ...

```

I am doing an update by query like this:

```
client.UpdateByQuery<Visitor>(u => u
.Script(script => script
    .Inline(@"
	...
    ")
 )
.ScrollSize(10000)
.RequestsPerSecond(-1)
.Refresh(false)

```

The problem I have is that when I run the update by query it take around 8 second to update 30000 visitors, but if I change the index RefreshInterval to 30 seconds then the update takes 100 miliseconds to run. So my guess is that Elasticsearch it is just ignoring the refresh=false query string in this case and it is just refresing the index after the update.

What I expect is to avoid the re-index and run this update in 100 ms even if I just leave the index refresh interval to 1 second as it is by default.

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [January 1, 2018, 7:31pm UTC](https://discuss.elastic.co/t/prevent-elasticsearch-re-index-on-update-by-query/113446/2 "2018-01-01T19:31:19Z")

</div>

The `Refresh` parameter of the `UpdateByQuery` operation only controls the refresh that happens _after_ the update completes and it does not controls the standard background refreshes that Elasticsearch does.

If you have `RefreshInterval` set to a value above `-1` Elasticsearch will still keep doing background refreshes, regardless of the `Refresh` parameter of the `UpdateByQuery` operation.

---

<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:** [January 29, 2018, 7:31pm UTC](https://discuss.elastic.co/t/prevent-elasticsearch-re-index-on-update-by-query/113446/3 "2018-01-29T19:31:46Z")

</div>

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