            (org.apache.lucene.facet.taxonomy.directory DirectoryTaxonomyWriter DirectoryTaxonomyReader)
            (org.apache.lucene.index IndexWriter IndexReader IndexWriterConfig DirectoryReader)
            (org.apache.lucene.search Query ScoreDoc SearcherManager IndexSearcher)
-           (org.apache.lucene.store NIOFSDirectory Directory)))
+           (org.apache.lucene.store NIOFSDirectory Directory NoSuchDirectoryException)))
 
 (declare use-searcher)
 (declare use-writer)
 (declare bootstrap-indexes)
-(declare get-search-manager)
+(declare get-smanager-taxo)
+(declare try-close-manager-taxo)
 
 (def root* (atom default-root))
 (def identifier* (atom default-identifier))
-(def name->smanager* (atom {}))
+(def name->smanager-taxo* (atom {}))
 
 (def acceptable-name-pattern (re-pattern "[^a-zA-Z_0-9-]"))
 (def shard-suffix "-shard-")

             (.toString dir)
             " Got exception while close()ing the writer,and directory is still locked."
             " Unlocking it. "
             "[ should never happen, there is a race between this IndexWriter/unlock and other process/thread IndexWriter/open ]"
             " Exception: " (ex-str e))))

(defn safe-close-writer [^IndexWriter writer]

(defn new-taxo-reader ^DirectoryTaxonomyReader [name]
  (DirectoryTaxonomyReader. (new-index-directory (taxo-dir-prefix name) "__taxo__")))

(defn try-new-taxo-reader ^DirectoryTaxonomyReader [name]
  (try
    (new-taxo-reader name)
    (catch Exception e
      (if (instance? NoSuchDirectoryException e)
        (do
          (log/warn (ex-str e))
          (let [writer ^DirectoryTaxonomyWriter (new-taxo-writer name)]
            (.commit writer)
            (.close writer))
          (new-taxo-reader name))))))

(defn new-index-reader ^IndexReader [name]
  (with-open [writer (new-index-writer name)]
    (DirectoryReader/open ^IndexWriter writer false)))

(defn new-searcher-manager ^SearcherManager [name]
  (SearcherManager. (new-index-directory (root-identifier-path) name) nil))

(defn sharded [index x-shard]
  (let [shard (int-or-parse x-shard)]
    (str (as-str index) shard-suffix (str shard))))

(defn reset-search-managers []
  (doseq [[name [manager taxo]] @name->smanager-taxo*]
    (log/info "\tclosing: " name " " manager)
    (try-close-manager-taxo manager taxo))
  (reset! name->smanager-taxo* {}))

(defn use-searcher [index callback]
  (let [[^SearcherManager manager taxo] (get-smanager-taxo index)
        searcher ^IndexSearcher (.acquire manager)]
    (try
      (callback searcher taxo)
      (finally (.release manager searcher)))))

(defn log-close-err [^Directory dir ^Throwable e]
