Prevent Elasticsearch re-index on update by query


(Adriano) #1

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.


(Thiago Souza) #2

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.


(system) #3

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