diff --git a/plugins/inputs/elasticsearch_query/elasticsearch_query_test.go b/plugins/inputs/elasticsearch_query/elasticsearch_query_test.go
index <HASH>..<HASH> 100644
--- a/plugins/inputs/elasticsearch_query/elasticsearch_query_test.go
+++ b/plugins/inputs/elasticsearch_query/elasticsearch_query_test.go
@@ -568,8 +568,13 @@ func setupIntegrationTest() error {
 		return err
 	}
 
-	// wait 5s (default) for Elasticsearch to index, so results are consistent
-	time.Sleep(time.Second * 5)
+	// force elastic to refresh indexes to get new batch data
+	ctx := context.Background()
+	_, err = e.esClient.Refresh().Do(ctx)
+	if err != nil {
+		return err
+	}
+
 	return nil
 }
test: force elasticsearch to index batch data (#<I>)