     date = Timex.now
            |> Timex.shift(days: -within_days)
            |> Timex.format!("%Y-%m-%d", :strftime)
-    update_in(query[:query][:bool][:filter], &([%{range: %{created_at: %{gte: date}}} | &1]))
+    update_bool(query, :filter, &([%{range: %{created_at: %{gte: date}}} | &1]))
+  end
+
+  defp boost_recent(query, true) do
+    recent_boost = %{gauss: %{created_at: %{scale: "3h", offset: "1d"}}, weight: 1}
+    update_in(query[:query][:function_score][:functions], &([recent_boost | &1]))
+  end
+
+  defp boost_recent(query, _) do
+    recent_boost = %{gauss: %{created_at: %{scale: "3d", offset: "1d"}}, weight: 1000}
+    update_in(query[:query][:function_score][:functions], &([recent_boost | &1]))
+  end
+
+  defp update_bool(query, type, fun) do
+    update_in(query[:query][:function_score][:query][:bool][type], fun)
   end
 
   defp search_post_index(query, opts) do

      results = Client.search(PostIndex.index_name(), [PostIndex.post_doc_type], query).body
    end

    posts = results["hits"]["hits"]
            |> Enum.map(&(String.to_integer(&1["_id"])))
            |> Content.posts_by_ids(opts)



  defp build_author_query(query, nil) do
    author_query = filter_private_authors(author_query())
    update_bool(query, :filter, &([author_query | &1]))
  end
  defp build_author_query(query, _current_user) do
    update_bool(query, :filter, &([author_query() | &1]))
  end

  defp filter_private_authors(author_query) do
    update_in(author_query[:has_parent][:query][:bool][:filter], &([%{term: %{is_public: true}} | &1]))
  end

  defp build_pagination_query(query, nil, nil), do: query
