Skip to content

Commit

Permalink
Improve spellcheck response transformation for RESP3
Browse files Browse the repository at this point in the history
  • Loading branch information
alisaifee committed Aug 23, 2023
1 parent 25a9bf9 commit 8f064e8
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions coredis/modules/response/_callbacks/search.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from collections import OrderedDict
from collections import ChainMap, OrderedDict
from functools import partial

from coredis._json import json
Expand Down Expand Up @@ -235,11 +235,7 @@ def transform_3(
if isinstance(response, list):
return self.transform(response, **options)
else:
suggestions = {}
for key, result in response["results"].items():
ordered = OrderedDict()
for res in result:
for sugg, score in res.items():
ordered[sugg] = score
suggestions[key] = ordered
return suggestions
return {
key: OrderedDict(ChainMap(*result))
for key, result in response["results"].items()
}

0 comments on commit 8f064e8

Please sign in to comment.