Repository: bookwyrm-social/bookwyrm

Issue:
Incorrect import of book from Goodreads
**Describe the bug**
I attempted to import my Goodreads library (https://www.goodreads.com/user/show/986159-nikhil) into Bookwyrm. I noticed the book _Dark Fiber: Tracking Critical Internet Culture_ ([bookwyrm](https://bookwyrm.social/book/120984), [goodreads](https://www.goodreads.com/book/show/1371653.Dark_Fiber); ISBN 9780262122498) in my library, which was not a book on my Goodreads list. Based on the order the imported books began showing up in my library, I think (but cannot confirm) that this was an incorrect import of the book _Ganhadores: A greve negra de 1857 na Bahia_ ([goodreads](https://www.goodreads.com/book/show/49417547-ganhadores); ISBN 9788535932430).

**To Reproduce**
Steps to reproduce the behavior:
1. Export Goodreads CSV for account https://www.goodreads.com/user/show/986159-nikhil
2. Navigate to https://bookwyrm.social/import
3. Upload CSV with format `GoodReads (CSV)`.
4. Navigate to https://bookwyrm.social/user/nikhilarundesai/books and see error

**Expected behavior**
The book _Dark Fiber_ does not appear in my BookWyrm library.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
    - OS: Mac OS
    - Browser: Chrome
    - Version: 90.0.4430.212 (Official Build) (x86_64)

**Additional context**
Add any other context about the problem here.



Discussion:
I tried to find a Bookwyrm entry for _Ganhadores_, but a search (https://bookwyrm.social/search/?q=ganhadores) is consistently giving a 502 Bad Gateway.
Searching the ISBN yielded no results: https://bookwyrm.social/search/?q=9788535932430
I can provide/attach the original Goodreads CSV export if it would be helpful.
I'm having problems with search right now, which I think explains both why the incorrect book was matched, and why you're getting 502 errors when tryin to search. (I was able to load the search page just now - I have a temporary fix in place that should be keeping the errors at bay). 

It appears that that book isn't present in any of the data sources available, which is why you aren't able to find it in search and can't match it from the CSV. You can add the book to OpenLibrary or Inventaire, or directly to BookWyrm (https://bookwyrm.social/create-book)
I just imported a whole CSV from Goodreads and experienced the same ; several books listed as "Successfully imported" are actually incorrectly matched.
I've shared all the mismatches here https://gist.github.com/yhancik/037a1333403fc4414bb27183b4cf17b0

It's perfectly understandable that not all books can be found, but maybe the system is too confidently matching books that don't match. Ideally, when there is a potential doubt, maybe the import report screen should ask the user to confirm if the found book is indeed matching the imported book?
Thank you, this gist is really useful! A possible solution here would be, if there's an isbn present, it should only search on isbn rather than falling back on author/title search. What instance are you on? I'd like to do a little digging into which connector is producing these results (I suspect inventaire)
I'm on https://lire.boitam.eu (poke @joachimesque ;))
Okay! It turns out a lot of these bad matches were probably coming from internal search, which is good, because that's easier to work on. Part of the solution may be tweaking the fuzzy match algorithm to improve the quality of the search rank (right now, it must have had a .996 confidence that it was picking the right text, which is clearly over-confident). I think it may make sense to not use fuzzy title/author search at all if an isbn is present. The downside is that if there was an unknown book by isbn, but a comparable edition edition existed, it wouldn't make that match, but I think it's better to be overly-cautious.

Asking for confirmation on ambiguous matches would also be great! That's an in-the-future feature unless someone else is excited to build it, though.
Yes, something like "We didn't find these books, but can offer the following potential matches" would be perfect, some day in the future!

Resolving patch:
diff --git a/bookwyrm/models/import_job.py b/bookwyrm/models/import_job.py
--- a/bookwyrm/models/import_job.py
+++ b/bookwyrm/models/import_job.py
@@ -75,7 +75,12 @@ class ImportItem(models.Model):
 
     def resolve(self):
         """try various ways to lookup a book"""
-        self.book = self.get_book_from_isbn() or self.get_book_from_title_author()
+        if self.isbn:
+            self.book = self.get_book_from_isbn()
+        else:
+            # don't fall back on title/author search is isbn is present.
+            # you're too likely to mismatch
+            self.get_book_from_title_author()
 
     def get_book_from_isbn(self):
         """search by isbn"""


Test patch: