         # File lib/ferret/index.rb, line 515
    515:     def query_update(query, new_val)
    516:       @dir.synchrolock do
    517:         ensure_writer_open()
    518:         ensure_searcher_open()
    519:         docs_to_add = []
    520:         query = do_process_query(query)
    521:         @searcher.search_each(query) do |id, score|
    522:           document = @searcher[id].load
    523:           if new_val.is_a?(Hash)
    524:             document.merge!(new_val)
    525:           else new_val.is_a?(String) or new_val.is_a?(Symbol)
    526:             document[@default_input_field] = new_val.to_s
    527:           end
    528:           docs_to_add << document
    529:           @reader.delete(id)
    530:         end
    531:         ensure_writer_open()
    532:         docs_to_add.each {|doc| @writer << doc }
    533:         flush() if @auto_flush
    534:       end
    535:     end