         # File lib/ferret/index.rb, line 525
    525:     def query_update(query, new_val)
    526:       @dir.synchrolock do
    527:         ensure_writer_open()
    528:         ensure_searcher_open()
    529:         docs_to_add = []
    530:         query = do_process_query(query)
    531:         @searcher.search_each(query) do |id, score|
    532:           document = @searcher[id].load
    533:           if new_val.is_a?(Hash)
    534:             document.merge!(new_val)
    535:           else new_val.is_a?(String) or new_val.is_a?(Symbol)
    536:             document[@default_input_field] = new_val.to_s
    537:           end
    538:           docs_to_add << document
    539:           @reader.delete(id)
    540:         end
    541:         ensure_writer_open()
    542:         docs_to_add.each {|doc| @writer << doc }
    543:         flush() if @auto_flush
    544:       end
    545:     end