Why would the law make exemptions for running the search on on a computer that has the database.

Because outlawing the local facial recognition that software like Lightroom and Apple Photos has offered for decades would be extraordinarily silly?