anchor.diff:      (when (slot-value self 'auto-flush-p)
         (flush self))))
   
  +(defmethod query-update ((self index) query new-val)
  +  (let ((searcher (searcher self))
  +	(reader (reader self))
  +	(docs-to-add '())
  +	(query (process-query self query)))
  +    (let ((results (enumerate (search-each searcher query))))
  +      (dolist (result results)
  +	(destructuring-bind (id score) result
  +	  (let ((document (get-doc self id)))
  +	    (cond ((hash-table-p new-val)
  +		   (loop for name being the hash-key using (hash-value content) of new-val
  +		      do (setf (get-field document name) (string content))))
  +		  ((typep new-val 'document)
  +		   (setf document new-val))
  +		  (T
  +		   (setf (get-field document (getf (slot-value self 'options) :default-field))
  +			 (string new-val))))
  +	    (push document docs-to-add)
  +	    (delete reader id)))))
  +    (let ((writer (writer self)))
  +      (dolist (doc (reverse docs-to-add))
  +	(add-document writer doc))
  +      (when (slot-value self 'auto-flush-p)
  +	(flush self)))))
  +
  +(defmethod has-deletions-p ((self index))
  +  (has-deletions-p (reader self)))
  +
  +(defmethod has-writes ((self index))
  +  (slot-value self 'has-writes))
  +
  +(defmethod flush ((self index))
  +  (with-slots (reader writer searcher) self
  +    (when reader (close reader))
  +    (when writer (close writer))
  +    (setf reader nil
  +	  writer nil
  +	  searcher nil)))
  +
  +(defmethod optimize ((self index))
  +  (optimize (writer self))
  +  (flush self))
  +
  +(defmethod size ((self index))
  +  (num-docs (reader self)))
  +
  +(defmethod add-indexes ((self index) indexes)
  +  (when (> (length indexes) 0)
  +    (when (typep (elt indexes 0) 'index)
  +      (setf indexes (map 'array #'reader indexes)))
  +    (cond ((typep (elt indexes 0) 'index-reader)
  +	   (let ((reader (reader self)))
  +	     (setf indexes (remove reader indexes)))
  +	   (add-indexes (writer self) indexes))
  +	  ((typep (elt indexes 0) 'directory)
  +	   (setf indexes (remove (slot-value self 'dir) indexes))
  +	   (add-indexes (writer self) indexes))
  +	  (T
  +	   (error "Unknown index type ~S when trying to merge indexes." (elt indexes 0))))))
  +
  +(defmethod persist ((self index) directory &key (create-p T))
  +  (flush self)
  +  (with-slots (dir options) self
  +    (let ((old-dir dir))
  +      (cond ((stringp directory)
  +	     (setf dir (make-instance 'fs-directory
  +				      :path directory
  +				      :create-p create-p))
  +	     (setf (getf options :close-dir) T))
  +	    ((typep directory 'directory)
  +	     (setf dir directory)))
  +      (add-indexes (writer self) (vector old-dir)))))
  +
  +
   
   (defmethod ensure-writer-open ((self index))
     (with-slots (open-p writer reader dir options searcher) self
  
positive.code:    (dir)
     (has-writes-p :initform NIL)
     (reader :initform nil)
     (writer :initform nil)
     (close-dir-p)
     (auto-flush-p)
     (default-search-field)
     (default-field)
     (analyzer)
     (open-p)
     (options :initarg :options)
     (qp))
    (:default-initargs
     :options '()))
     
  
  (defmethod initialize-instance ((self index) &key path)
    (with-slots (dir close-dir-p create-p analyzer writer) self
      (cond (path
  	   (assert (not dir))
  	   (setf dir (make-fs-directory path create-p))
  	   (setf close-dir-p T))
  	  (dir
  	   )
  	  (T
  	   (setf create-p T)
  	   (setf dir (make-instance 'ram-directory))))
      ;; Create the index if need be
      (setf writer (make-instance 'index-writer
  				:directory dir))
      (setf analyzer (analyzer writer))
      (close writer)
      (setf writer nil)))
  
  (defmethod close ((self index))
    (with-slots (open-p reader writer dir) self
  
negative.code: 	;; been added.
  	(setf (fields qp) (string (get-field-names reader)))
  	(parse qp query))
        query))
  