   [es index-name doc & {:keys [stream?] :as options}]
   {:pre [(doc-type doc) (or (nil? (doc-id doc)) (valid-id? (doc-id doc)))]}
   (let [body ((if stream? piped-json-body json-body) doc)
-        type (doc-type doc)]
+        type-name (doc-type doc)]
     (if-let [id (doc-id doc)]
-      (http-put (url es index-name type id "_create") body)
-      (http-post (url es index-name type) body))))
+      (http-put (url es index-name type-name id "_create") body)
+      (http-post (url es index-name type-name) body))))
 
 (defn doc-index
   "Index doc in index-name using the ES index operation (creates it if it

  (when (and (string? index-name) (pos? (count index-name)))
    index-name))

(defn valid-type?
  "True if type is a keyword or non-empty string"
  [type]
  (when (or (keyword type) (and (string? type) (pos? (count type))))
    type))

(defn valid-id?
  "True if id is a keyword, symbol, or non-empty string"

  (search* es index-names query options))

(defn doc-type
  "Gets the type-name (via :_type or \"_type\") from doc."
  [doc]
  (if-let [type-name (or (:_type doc) (get doc "_type"))]
    (name type-name)))

(defn doc-id
  "Gets the id (via :_id or \"_id\") from doc."
