   end
 
   def user_search(terms, %{current_user: nil} = opts) do
-    base_query()
-    |> build_user_query(terms)
-    |> filter_spam
-    |> filter_nsfw(opts[:allow_nsfw])
-    |> filter_nudity(opts[:allow_nudity])
+    terms
+    |> build_default_user_search_query(opts)
+    |> filter_private_users
     |> search_user_index
   end
-  def user_search(terms, %{allow_nsfw: allow_nsfw, allow_nudity: allow_nudity, current_user: current_user} = opts) do
+  def user_search(terms, %{current_user: current_user} = opts) do
     following_ids = Network.following_ids(current_user)
-    base_query()
-    |> build_pagination_query(opts[:page], opts[:per_page])
-    |> build_user_query(terms)
+    terms
+    |> build_default_user_search_query(opts)
     |> build_relationship_query(following_ids)
-    |> filter_spam
-    |> filter_nsfw(allow_nsfw)
-    |> filter_nudity(allow_nudity)
     |> filter_blocked(current_user)
     |> search_user_index
   end

          ],
          must:     [],
          should:   [],
        }
      }
    }
  end

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

    update_in(query[:query][:bool][:must_not], &([%{term: %{is_spammer: true}} | &1]))
  end

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

  defp search_user_index(query) do
    ids = Client.search(UserIndex.index_name(), UserIndex.doc_types(), query).body["hits"]["hits"]
          |> Enum.map(&(String.to_integer(&1["_id"])))
