tweaks search rankings for better results

This commit is contained in:
Mouse Reeve 2020-11-13 11:03:39 -08:00
parent 6300c37a4e
commit 28e1c9525c
2 changed files with 12 additions and 15 deletions

View file

@ -13,16 +13,16 @@ class Connector(AbstractConnector):
that gets implemented it will totally rule '''
vector = SearchVector('title', weight='A') +\
SearchVector('subtitle', weight='B') +\
SearchVector('author_text', weight='A') +\
SearchVector('author_text', weight='C') +\
SearchVector('isbn_13', weight='A') +\
SearchVector('isbn_10', weight='A') +\
SearchVector('openlibrary_key', weight='B') +\
SearchVector('goodreads_key', weight='B') +\
SearchVector('asin', weight='B') +\
SearchVector('oclc_number', weight='B') +\
SearchVector('remote_id', weight='B') +\
SearchVector('description', weight='C') +\
SearchVector('series', weight='C')
SearchVector('openlibrary_key', weight='C') +\
SearchVector('goodreads_key', weight='C') +\
SearchVector('asin', weight='C') +\
SearchVector('oclc_number', weight='C') +\
SearchVector('remote_id', weight='C') +\
SearchVector('description', weight='D') +\
SearchVector('series', weight='D')
results = models.Edition.objects.annotate(
search=vector

View file

@ -73,14 +73,11 @@ class ImportItem(models.Model):
def get_book_from_isbn(self):
''' search by isbn '''
search_result = books_manager.first_search_result(
self.isbn, min_confidence=0.995
self.isbn, min_confidence=0.999
)
if search_result:
try:
# don't crash the import when the connector fails
# raises ConnectorException
return books_manager.get_or_create_book(search_result.key)
except ConnectorException:
pass
return None
@ -91,7 +88,7 @@ class ImportItem(models.Model):
self.data['Author']
)
search_result = books_manager.first_search_result(
search_term, min_confidence=0.995
search_term, min_confidence=0.999
)
if search_result:
# raises ConnectorException