@@ -36,11 +36,10 @@ def get_model_attr(name):
36
36
return partial (_getattr , name = name )
37
37
38
38
39
- def aggregator (aggregated , resp ):
40
- for hit in resp .hits :
41
- if "_highlightResult" in hit :
42
- hit .pop ("_highlightResult" )
43
- aggregated .append (hit )
39
+ def sanitize (hit ):
40
+ if "_highlightResult" in hit :
41
+ hit .pop ("_highlightResult" )
42
+ return hit
44
43
45
44
46
45
class AlgoliaIndexError (Exception ):
@@ -499,13 +498,19 @@ def reindex_all(self, batch_size=1000):
499
498
logger .debug ("APPLY SETTINGS ON %s_tmp" , self .index_name )
500
499
501
500
rules = []
502
- self .__client .browse_rules (self .index_name , lambda _resp : aggregator (rules , _resp ))
501
+ self .__client .browse_rules (
502
+ self .index_name ,
503
+ lambda _resp : rules .extend ([sanitize (_hit .to_dict ()) for _hit in _resp .hits ]),
504
+ )
503
505
if len (rules ):
504
506
logger .debug ("Got rules for index %s: %s" , self .index_name , rules )
505
507
should_keep_rules = True
506
508
507
509
synonyms = []
508
- self .__client .browse_synonyms (self .index_name , lambda _resp : aggregator (synonyms , _resp ))
510
+ self .__client .browse_synonyms (
511
+ self .index_name ,
512
+ lambda _resp : synonyms .extend ([sanitize (_hit .to_dict ()) for _hit in _resp .hits ]),
513
+ )
509
514
if len (synonyms ):
510
515
logger .debug ("Got synonyms for index %s: %s" , self .index_name , rules )
511
516
should_keep_synonyms = True
0 commit comments