 
   defp build_author_query(query, nil) do
     author_query = filter_private_authors(author_query())
-    update_in(query[:query][:bool][:filter], &([author_query | &1]))
+    update_bool(query, :filter, &([author_query | &1]))
   end
-  defp build_author_query(query, current_user) do
-    update_in(query[:query][:bool][:filter], &([author_query() | &1]))
+  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

    |> update_in([:from], &(&1 = page * per_page))
    |> update_in([:size], &(&1 = per_page))
  end
  defp build_pagination_query(query, _), do: query

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

  defp build_language_query(query, nil), do: query
  defp build_language_query(query, language) do
    language_boost = Application.get_env(:ello_search, :language_boost_factor)
    update_in(query[:query][:bool][:should], &([%{term: %{detected_language: %{value: language, boost: language_boost}}} | &1]))
  end

  defp filter_days(query, nil), do: query

      size: 10,
      stored_fields: [],
      query: %{
        function_score: %{
          query: %{
            bool: %{
              must:     [],
              should:   [],
              filter:   [],
              must_not: [
                %{term: %{is_comment: true}},
                %{term: %{is_hidden:  true}},
                %{term: %{is_repost:  true}},
              ]
            }
          },
          functions: [],
          score_mode: "sum",
          boost_mode: "sum"
        }
      }
    }
  end

  defp build_text_content_query(query, nil), do: query
  defp build_text_content_query(query, terms) do
    text_boost = Application.get_env(:ello_search, :text_content_boost_factor)
    update_bool(query, :must, &([%{query_string: %{query: terms, fields: ["text_content"], boost: text_boost}} | &1]))
  end

  defp build_mention_query(query, nil), do: query
  defp build_mention_query(query, terms) do
    mention_boost = Application.get_env(:ello_search, :mention_boost_factor)
    update_bool(query, :should, &([%{match: %{mentions: %{query: terms, boost: mention_boost}}} | &1]))
  end

  defp build_hashtag_query(query, nil), do: query
  defp build_hashtag_query(query, terms) do
    hashtag_boost = Application.get_env(:ello_search, :hashtag_boost_factor)
    update_bool(query, :should, &([%{match: %{hashtags: %{query: terms, boost: hashtag_boost}}} | &1]))
  end

  defp filter_nsfw(query, true), do: query
  defp filter_nsfw(query, false) do
    update_bool(query, :must_not, &([%{term: %{is_adult_content: true}} | &1]))
  end

  defp filter_nudity(query, true), do: query
  defp filter_nudity(query, false) do
    update_bool(query, :must_not, &([%{term: %{has_nudity: true}} | &1]))
  end

  defp filter_blocked(query, nil), do: query
  defp filter_blocked(query, user) do
    update_bool(query, :must_not, &([%{terms: %{author_id: user.all_blocked_ids}} | &1]))
  end

  defp author_query do
