nickva commented on code in PR #5288:
URL: https://github.com/apache/couchdb/pull/5288#discussion_r1792218257
##########
src/nouveau/src/nouveau_fabric_search.erl:
##########
@@ -159,15 +159,18 @@ simplify_hit(#{} = Hit) ->
Hit#{<<"fields">> => simplify_fields(Fields)}.
simplify_fields(Fields) when is_list(Fields) ->
- Fun = fun(Field, Acc) ->
- {Key, Value} = simplify_field(Field),
- Acc#{Key => Value}
+ Grouped = maps:groups_from_list(
+ fun(Field) -> maps:get(<<"name">>, Field) end,
+ fun(Field) -> maps:get(<<"value">>, Field) end,
Review Comment:
Minor suggestion: direct field access with a map is a bit more idiomatic,
could do something like:
```erlang
maps:groups_from_list(
fun(#{<<"name">> := Name}) -> Name end,
fun(#{<<"value">> := Value}) -> Value end,
Fields
)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]