   "Clears the tile-spec index"
   []
   (log/infof "clearing the tile-spec index")
-  (es/clear! (get-in config [:search :index-url])))
+  (log/spy :trace (es/clear! (get-in config [:search :index-url]))))
 
 (defn search
   "Submits a query to the index.  Query should conform to elasticsearch

   "Converts a tile-spec to an index entry."
  [tile-spec]
  (log/debugf "converting tile-spec to index entry")
  (log/tracef "====> for tile-spec: %s" tile-spec)
  (str (json/write-str {"index" {"_retry_on_conflict" 3}}) "\n"
       (json/write-str tile-spec) "\n"))



  ([api-url query]
   (log/debugf "querying the index")
   (es/search api-url query (get-in config [:search :max-result-size]))))

(defn result
  "Extracts tile-specs from search results"
  [search-results]
  (log/debugf "extracting tile-specs from search results")
  (log/spy :trace
           (map #(get % "_source")(get-in search-results ["hits" "hits"]))))

(defn save
  "Saves tile-specs to the ElasticSearch index."
  [tile-specs]
  (log/infof "saving index entries")
  (log/spy :trace
           (es/load! (get-in config [:search :bulk-api-url])
                     (pmap #(->> % +tags index-entry) (vectorize tile-specs))))
  tile-specs)
