You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "rnewson (via GitHub)" <gi...@apache.org> on 2024/10/08 16:44:17 UTC

[PR] send all stored values for a field [couchdb]

rnewson opened a new pull request, #5288:
URL: https://github.com/apache/couchdb/pull/5288

   ## Overview
   
   send all stored values for a field
   
   ## Testing recommendations
   
   covered by tests
   
   ## Related Issues or Pull Requests
   
   https://github.com/apache/couchdb/issues/5285
   
   ## Checklist
   
   - [x] Code is written and works correctly
   - [x] Changes are covered by tests
   - [ ] Any new configurable parameters are documented in `rel/overlay/etc/default.ini`
   - [ ] Documentation changes were made in the `src/docs` folder
   - [ ] Documentation changes were backported (separated PR) to affected branches
   


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] send all stored values for a field [couchdb]

Posted by "rnewson (via GitHub)" <gi...@apache.org>.
rnewson merged PR #5288:
URL: https://github.com/apache/couchdb/pull/5288


-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] send all stored values for a field [couchdb]

Posted by "rnewson (via GitHub)" <gi...@apache.org>.
rnewson commented on code in PR #5288:
URL: https://github.com/apache/couchdb/pull/5288#discussion_r1792225468


##########
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:
   yup, good catch, they will always be present



-- 
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] send all stored values for a field [couchdb]

Posted by "nickva (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org