mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 21:11:16 +00:00
tweaks search rankings for better results
This commit is contained in:
parent
6300c37a4e
commit
28e1c9525c
2 changed files with 12 additions and 15 deletions
|
@ -13,16 +13,16 @@ class Connector(AbstractConnector):
|
||||||
that gets implemented it will totally rule '''
|
that gets implemented it will totally rule '''
|
||||||
vector = SearchVector('title', weight='A') +\
|
vector = SearchVector('title', weight='A') +\
|
||||||
SearchVector('subtitle', weight='B') +\
|
SearchVector('subtitle', weight='B') +\
|
||||||
SearchVector('author_text', weight='A') +\
|
SearchVector('author_text', weight='C') +\
|
||||||
SearchVector('isbn_13', weight='A') +\
|
SearchVector('isbn_13', weight='A') +\
|
||||||
SearchVector('isbn_10', weight='A') +\
|
SearchVector('isbn_10', weight='A') +\
|
||||||
SearchVector('openlibrary_key', weight='B') +\
|
SearchVector('openlibrary_key', weight='C') +\
|
||||||
SearchVector('goodreads_key', weight='B') +\
|
SearchVector('goodreads_key', weight='C') +\
|
||||||
SearchVector('asin', weight='B') +\
|
SearchVector('asin', weight='C') +\
|
||||||
SearchVector('oclc_number', weight='B') +\
|
SearchVector('oclc_number', weight='C') +\
|
||||||
SearchVector('remote_id', weight='B') +\
|
SearchVector('remote_id', weight='C') +\
|
||||||
SearchVector('description', weight='C') +\
|
SearchVector('description', weight='D') +\
|
||||||
SearchVector('series', weight='C')
|
SearchVector('series', weight='D')
|
||||||
|
|
||||||
results = models.Edition.objects.annotate(
|
results = models.Edition.objects.annotate(
|
||||||
search=vector
|
search=vector
|
||||||
|
|
|
@ -73,14 +73,11 @@ class ImportItem(models.Model):
|
||||||
def get_book_from_isbn(self):
|
def get_book_from_isbn(self):
|
||||||
''' search by isbn '''
|
''' search by isbn '''
|
||||||
search_result = books_manager.first_search_result(
|
search_result = books_manager.first_search_result(
|
||||||
self.isbn, min_confidence=0.995
|
self.isbn, min_confidence=0.999
|
||||||
)
|
)
|
||||||
if search_result:
|
if search_result:
|
||||||
try:
|
# raises ConnectorException
|
||||||
# don't crash the import when the connector fails
|
|
||||||
return books_manager.get_or_create_book(search_result.key)
|
return books_manager.get_or_create_book(search_result.key)
|
||||||
except ConnectorException:
|
|
||||||
pass
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +88,7 @@ class ImportItem(models.Model):
|
||||||
self.data['Author']
|
self.data['Author']
|
||||||
)
|
)
|
||||||
search_result = books_manager.first_search_result(
|
search_result = books_manager.first_search_result(
|
||||||
search_term, min_confidence=0.995
|
search_term, min_confidence=0.999
|
||||||
)
|
)
|
||||||
if search_result:
|
if search_result:
|
||||||
# raises ConnectorException
|
# raises ConnectorException
|
||||||
|
|
Loading…
Reference in a new issue