database: Rename internal find_messages_by_term to find_doc_ids