     escaped = Macro.escape(types)
 
     quote do
-      def __es_analysis__(:to_map), do: %{analysis: Funcs.to_map(unquote(escaped))}
+      def __es_analysis__(:to_map) do
+        analysis = %{analysis: Funcs.to_map(unquote(escaped))}
+        Map.merge Funcs.to_map(unquote(options)), analysis
+      end
       def __es_analysis__(:as_json), do: __es_analysis__ :to_map
       def __es_analysis__(:types), do: unquote(escaped)
       unquote(quoted)
       def __es_analysis__(:type, _), do: nil
+
+      def __es_analysis__(:settings), do: unquote(options)
     end
   end
 

  end

  @doc false
  def __es_analyses__(analyses) do
    types =
      Enum.reduce analyses, [], fn {type, name, opts}, acc ->
        m = Keyword.new([{name, opts}])

  @doc false
  defmacro __using__(_) do
    quote do
      import Analysis, only: [settings: 1, settings: 2]

      Module.register_attribute(__MODULE__, :es_analyses, accumulate: true)
    end
  end

  defmacro settings([do: block]) do
    es_analysis(__MODULE__, [], block)
  end

  defmacro settings(options, [do: block]) do
    es_analysis(__MODULE__, options, block)
  end

  defmacro settings(options) do
  end

  # imitational function.
  defmacro analysis([do: block]), do: block

  @doc false
  def es_analysis(_mod, options, block) do
    quote do
      # mod = unquote(mod)

