Skip to content

Commit 76ab577

Browse files
committed
fix: remove highlightResult from response
1 parent b71984f commit 76ab577

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

algoliasearch_django/models.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ def get_model_attr(name):
3636
return partial(_getattr, name=name)
3737

3838

39+
def aggregator(aggregated, resp):
40+
for hit in resp.hits:
41+
if "_highlightResult" in hit:
42+
hit.pop("_highlightResult")
43+
aggregated.append(hit)
44+
45+
3946
class AlgoliaIndexError(Exception):
4047
"""Something went wrong with an Algolia Index."""
4148

@@ -492,17 +499,13 @@ def reindex_all(self, batch_size=1000):
492499
logger.debug("APPLY SETTINGS ON %s_tmp", self.index_name)
493500

494501
rules = []
495-
self.__client.browse_rules(
496-
self.index_name, lambda _resp: rules.extend(_resp.hits)
497-
)
502+
self.__client.browse_rules(self.index_name, lambda _resp: aggregator(rules, _resp))
498503
if len(rules):
499504
logger.debug("Got rules for index %s: %s", self.index_name, rules)
500505
should_keep_rules = True
501506

502507
synonyms = []
503-
self.__client.browse_synonyms(
504-
self.index_name, lambda _resp: synonyms.extend(_resp.hits)
505-
)
508+
self.__client.browse_synonyms(self.index_name, lambda _resp: aggregator(synonyms, _resp))
506509
if len(synonyms):
507510
logger.debug("Got synonyms for index %s: %s", self.index_name, rules)
508511
should_keep_synonyms = True

0 commit comments

Comments
 (0)