nickva commented on code in PR #5286: URL: https://github.com/apache/couchdb/pull/5286#discussion_r1792531644
########## src/nouveau/src/nouveau_fabric_search.erl: ########## @@ -215,11 +222,43 @@ convert_item(Item) -> maps:get(<<"value">>, Item) end. -merge_facets(FacetsA, null, _Limit) -> +top_n_facets(SearchResults, TopN) -> + After = SearchResults#{ + <<"counts">> => top_n_facets(<<"counts">>, SearchResults, TopN), + <<"ranges">> => top_n_facets(<<"ranges">>, SearchResults, TopN) + }, + After. + +top_n_facets(Key, SearchResults, TopN) -> + Facets = maps:get(Key, SearchResults, null), + top_n_facets_int(Facets, TopN). + +top_n_facets_int(null, _TopN) -> + null; +top_n_facets_int(Facets, TopN) when is_map(Facets), is_integer(TopN), TopN > 0 -> Review Comment: `is_map(Facets)` can be replaced with `top_n_facets_int(#{} = Facets,...)` but either way is fine, whichever looks better to you -- 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-unsubscr...@couchdb.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org