   [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"

  "Creates a bulk operation to index a document in ES."
  ([source]
     (doc-bulk-index (:_type source) (:_id source) source))
  ([type-name id source]
     (doc-bulk-index (:_index source) type-name id source))
  ([index-name type-name id source]
     {:pre [(or (nil? index-name)
                (valid-index-name? index-name))
            (or (nil? (:_index source))
                (and (valid-index-name? (:_index source))
                     (or (nil? index-name)
                         (= index-name (:_index source)))))
            (valid-type-name? type-name)
            (or (nil? (:_type source))
                (and (valid-type-name? (:_type source))
                     (= (name type-name) (:_type source))))
            (valid-id? id)
            (or (nil? (:_id source))
                (and (valid-id? (:_id source))
