I would do something like this. I didn't try to run it, but see below.
Code:
# I assume you have an old API db reference. Get a new_api reference
ndb = db.new_api
book_to_id_map = {}
for i, title, last_modified, isbn in extracted_ids:
# Get the existing identifiers for the book
identifiers_for_book = ndb.field_for('identifiers', i)
# Add/replace the ISBN identifer
identifiers_for_book['isbn'] = isbn
# Save the (probably) updated list of identifiers
book_to_id_map[i] = identifiers_for_book
# Set all the books' identifier values
ndb.set_field('identifiers', book_to_id_map)
As a test I ran this in the template tester. It worked. The first 4 books with more than one identifier ended up including "isbn:grumblebunny"
Code:
python:
def evaluate(book, context):
db = context.db.new_api
ids = list(db.search("identifiers:#>2"))
book_to_id_map = {}
for id_ in ids[0:4]:
identifiers_for_book = db.field_for('identifiers', id_)
identifiers_for_book['isbn'] = 'grumblebunny'
book_to_id_map[id_] = identifiers_for_book
db.set_field('identifiers', book_to_id_map)
return 'foo'