         # File lib/ferret/index.rb, line 674
    674:     def query_update(query, new_val)
    675:       @dir.synchronize do
    676:         ensure_writer_open()
    677:         ensure_searcher_open()
    678:         docs_to_add = []
    679:         query = do_process_query(query)
    680:         @searcher.search_each(query, :limit => :all) do |id, score|
    681:           document = @searcher[id].load
    682:           if new_val.is_a?(Hash)
    683:             document.merge!(new_val)
    684:           else new_val.is_a?(String) or new_val.is_a?(Symbol)
    685:             document[@default_input_field] = new_val.to_s
    686:           end
    687:           docs_to_add << document
    688:           @reader.delete(id)
    689:         end
    690:         ensure_writer_open()
    691:         docs_to_add.each {|doc| @writer << doc }
    692:         flush() if @auto_flush
    693:       end
    694:     end