Skip to content

Commit

Permalink
core: Add facets property to search_result (#1606)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer authored and mworrell committed Feb 22, 2017
1 parent 183776c commit c36d6c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 13 additions & 2 deletions include/zotonic.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,19 @@
%% Default page length for search
-define(SEARCH_PAGELEN, 20).

%% Used for search results
-record(search_result, {result=[], page=1, pagelen, total, all, pages, next, prev}).
%% @doc A set of search results
-record(search_result, {
result = [] :: list(),
page = 1 :: pos_integer(),
pagelen :: pos_integer(),
total :: non_neg_integer(),
all :: non_neg_integer(),
pages :: non_neg_integer(),
next,
prev,
facets = [] :: list()
}).

-record(m_search_result, {search_name, search_props, result, page, pagelen, total, pages, next, prev}).
-record(search_sql, {select, from, where="", order="", group_by="", limit, tables=[], args=[],
cats=[], cats_exclude=[], cats_exact=[], run_func, extra=[], assoc=false}).
Expand Down
3 changes: 3 additions & 0 deletions src/models/m_search.erl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ get_result(props, Result, _Context) ->
Result#m_search_result.search_props;
get_result(total, Result, _Context) ->
Result#m_search_result.total;
get_result(facets, Result, _Context) ->
#search_result{facets = Facets} = Result#m_search_result.result,
Facets;
get_result(pages, Result, _Context) ->
case Result#m_search_result.result of
#search_result{pages=Pages} -> Pages;
Expand Down

0 comments on commit c36d6c1

Please sign in to comment.