@@ -66,7 +66,7 @@ def test_bulk_actions_remain_unchanged(sync_client):
66
66
def test_bulk_all_documents_get_inserted (sync_client ):
67
67
docs = [{"answer" : x , "_id" : x } for x in range (100 )]
68
68
for ok , item in helpers .streaming_bulk (
69
- sync_client , docs , index = "test-index"
69
+ sync_client , docs , index = "test-index" , refresh = True ,
70
70
):
71
71
assert ok
72
72
@@ -171,6 +171,7 @@ def test_bulk_rejected_documents_are_retried(sync_client):
171
171
chunk_size = 1 ,
172
172
max_retries = 1 ,
173
173
initial_backoff = 0 ,
174
+ refresh = True ,
174
175
)
175
176
)
176
177
assert 3 == len (results )
@@ -209,6 +210,7 @@ def test_bulk_rejected_documents_are_retried_when_bytes_or_string(
209
210
chunk_size = 1 ,
210
211
max_retries = 1 ,
211
212
initial_backoff = 0 ,
213
+ refresh = True ,
212
214
)
213
215
)
214
216
assert 3 == len (results )
@@ -245,6 +247,7 @@ def test_bulk_rejected_documents_are_retried_at_most_max_retries_times(sync_clie
245
247
chunk_size = 1 ,
246
248
max_retries = 1 ,
247
249
initial_backoff = 0 ,
250
+ refresh = True ,
248
251
)
249
252
)
250
253
assert 3 == len (results )
@@ -286,7 +289,7 @@ def streaming_bulk():
286
289
287
290
def test_bulk_works_with_single_item (sync_client ):
288
291
docs = [{"answer" : 42 , "_id" : 1 }]
289
- success , failed = helpers .bulk (sync_client , docs , index = "test-index" )
292
+ success , failed = helpers .bulk (sync_client , docs , index = "test-index" , refresh = True )
290
293
291
294
assert 1 == success
292
295
assert not failed
@@ -296,7 +299,7 @@ def test_bulk_works_with_single_item(sync_client):
296
299
297
300
def test_all_documents_get_inserted (sync_client ):
298
301
docs = [{"answer" : x , "_id" : x } for x in range (100 )]
299
- success , failed = helpers .bulk (sync_client , docs , index = "test-index" )
302
+ success , failed = helpers .bulk (sync_client , docs , index = "test-index" , refresh = True )
300
303
301
304
assert 100 == success
302
305
assert not failed
@@ -307,7 +310,7 @@ def test_all_documents_get_inserted(sync_client):
307
310
def test_stats_only_reports_numbers (sync_client ):
308
311
docs = [{"answer" : x } for x in range (100 )]
309
312
success , failed = helpers .bulk (
310
- sync_client , docs , index = "test-index" , stats_only = True
313
+ sync_client , docs , index = "test-index" , refresh = True , stats_only = True
311
314
)
312
315
313
316
assert 100 == success
@@ -435,7 +438,7 @@ def test_order_can_be_preserved(sync_client):
435
438
for x in range (100 ):
436
439
bulk .append ({"index" : {"_index" : "test_index" , "_id" : x }})
437
440
bulk .append ({"answer" : x , "correct" : x == 42 })
438
- sync_client .bulk (operations = bulk )
441
+ sync_client .bulk (operations = bulk , refresh = True )
439
442
440
443
docs = list (
441
444
helpers .scan (
@@ -457,7 +460,7 @@ def test_all_documents_are_read(sync_client):
457
460
for x in range (100 ):
458
461
bulk .append ({"index" : {"_index" : "test_index" , "_id" : x }})
459
462
bulk .append ({"answer" : x , "correct" : x == 42 })
460
- sync_client .bulk (operations = bulk )
463
+ sync_client .bulk (operations = bulk , refresh = True )
461
464
462
465
docs = list (helpers .scan (sync_client , index = "test_index" , size = 2 ))
463
466
@@ -472,7 +475,7 @@ def test_scroll_error(sync_client):
472
475
for x in range (4 ):
473
476
bulk .append ({"index" : {"_index" : "test_index" }})
474
477
bulk .append ({"value" : x })
475
- sync_client .bulk (operations = bulk )
478
+ sync_client .bulk (operations = bulk , refresh = True )
476
479
477
480
with patch .object (sync_client , "options" , return_value = sync_client ), patch .object (
478
481
sync_client , "scroll"
@@ -734,7 +737,7 @@ def test_clear_scroll(sync_client):
734
737
for x in range (4 ):
735
738
bulk .append ({"index" : {"_index" : "test_index" }})
736
739
bulk .append ({"value" : x })
737
- sync_client .bulk (operations = bulk )
740
+ sync_client .bulk (operations = bulk , refresh = True )
738
741
739
742
with patch .object (sync_client , "options" , return_value = sync_client ), patch .object (
740
743
sync_client , "clear_scroll" , wraps = sync_client .clear_scroll
@@ -833,7 +836,7 @@ def reindex_setup(sync_client):
833
836
"type" : "answers" if x % 2 == 0 else "questions" ,
834
837
}
835
838
)
836
- sync_client .bulk (operations = bulk )
839
+ sync_client .bulk (operations = bulk , refresh = True )
837
840
838
841
839
842
@pytest .mark .usefixtures ("reindex_setup" )
@@ -843,6 +846,7 @@ def test_reindex_passes_kwargs_to_scan_and_bulk(sync_client):
843
846
"test_index" ,
844
847
"prod_index" ,
845
848
scan_kwargs = {"q" : "type:answers" },
849
+ bulk_kwargs = {"refresh" : True },
846
850
)
847
851
848
852
assert sync_client .indices .exists (index = "prod_index" )
@@ -860,6 +864,7 @@ def test_reindex_accepts_a_query(sync_client):
860
864
"test_index" ,
861
865
"prod_index" ,
862
866
query = {"query" : {"bool" : {"filter" : {"term" : {"type" : "answers" }}}}},
867
+ bulk_kwargs = {"refresh" : True },
863
868
)
864
869
865
870
assert sync_client .indices .exists (index = "prod_index" )
@@ -872,7 +877,7 @@ def test_reindex_accepts_a_query(sync_client):
872
877
873
878
@pytest .mark .usefixtures ("reindex_setup" )
874
879
def test_all_documents_get_moved (sync_client ):
875
- helpers .reindex (sync_client , "test_index" , "prod_index" )
880
+ helpers .reindex (sync_client , "test_index" , "prod_index" , bulk_kwargs = { "refresh" : True } )
876
881
877
882
assert sync_client .indices .exists (index = "prod_index" )
878
883
assert 50 == sync_client .count (index = "prod_index" , q = "type:questions" )["count" ]
@@ -904,6 +909,7 @@ def parent_child_reindex_setup(sync_client):
904
909
id = 47 ,
905
910
routing = 42 ,
906
911
body = {"some" : "data" , "question_answer" : {"name" : "answer" , "parent" : 42 }},
912
+ refresh = True ,
907
913
)
908
914
909
915
@@ -951,7 +957,7 @@ def reindex_data_stream_setup(sync_client):
951
957
"@timestamp" : (dt - timedelta (days = x )).isoformat (),
952
958
}
953
959
)
954
- sync_client .bulk (operations = bulk )
960
+ sync_client .bulk (operations = bulk , refresh = True )
955
961
sync_client .indices .put_index_template (
956
962
name = "my-index-template" ,
957
963
body = {
0 commit comments