This logic is still totally bonkers, but this change puts a hard limit
on how many iterations the loop can go through and makes the query that
selects which edition to display a little simpler.
This commit removes code that deduplicated search results for identifier
searches. If it was the case that multiple books have the same
identifier, in theory this would produce better search results, but in
practice this doesn't happen very much, is probably worth seeing when
it does, and worsens the performance of identifier search overall.
- uppercase ISBN before checking it's a number to account for trailing 'x'
- check maybe_isbn for search_identifiers search. Without this we are only searching external connectors, not locally!
ISBNs are always numeric except for when the check digit in ISBN-10s is a ten, indicated with a capital X.
These changes ensure that ISBNs are always upper-case so that a lower-case 'x' is not used when searching.
Additionally some ancient ISBNs have been printed without a leading zero (i.e. they only have 9 characters on the physical book). This change prepends a zero if something looks like an ISBN but only has 9 chars.
Since we get all the results quickly now, this aggregates all the
results that came back and sorts them by confidence, and returns the
highest confidence result. The confidences aren't great on free text
search, but conceptually that's how it should work at least.
It may make sense to aggregate the search results in all contexts, but
I'll propose that in a separate PR.