diff --git a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java index 046483a6b074f..615bdbf23a45a 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -4003,7 +4003,7 @@ public void beforeRefresh() {} @Override public void afterRefresh(boolean didRefresh) { - if (enableFieldHasValue) { + if (enableFieldHasValue && didRefresh) { try (Engine.Searcher hasValueSearcher = getEngine().acquireSearcher("field_has_value")) { setFieldInfos(FieldInfos.getMergedFieldInfos(hasValueSearcher.getIndexReader())); } catch (AlreadyClosedException ignore) {