Skip to content
This repository has been archived by the owner on Aug 12, 2021. It is now read-only.

Commit

Permalink
Add more fields to book keyword search index #84
Browse files Browse the repository at this point in the history
  • Loading branch information
rlskoeser committed Aug 6, 2018
1 parent 7e22e2c commit 93dc1ce
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions winthrop/books/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ def index_data(self):
'subject': [str(subject) for subject in self.subjects.all()],
'annotator': [str(annotator) for annotator in self.annotators()],
'pub_year': self.pub_year,
'publisher': self.publisher.name if self.publisher else '',
'pub_place': self.pub_place.name if self.pub_place else '',
'original_pub_info': self.original_pub_info,
'notes': self.notes,
# NOTE: this indicates whether the book is annotated, does not
# necessarily mean there are annotations documented in our system
'is_annotated': self.is_annotated,
Expand Down
12 changes: 12 additions & 0 deletions winthrop/books/tests/test_book_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,18 @@ def test_index_data(self):
assert not index_data['thumbnail_label']
assert index_data['author_sort'] == book.authors()[0].authorized_name
assert index_data['author'] == [str(author) for author in book.authors()]
assert index_data['publisher'] == book.publisher.name
assert index_data['pub_place'] == book.pub_place.name
assert index_data['original_pub_info'] == book.original_pub_info
assert index_data['notes'] == book.notes

# delete publisher, pub place to check error handling
book.publisher = None
book.pub_place = None
index_data = book.index_data()
assert index_data['publisher'] == ''
assert index_data['pub_place'] == ''


# associate digital edition from fixture (has no thumbnail)
book.digital_edition = Manifest.objects.first()
Expand Down
8 changes: 7 additions & 1 deletion winthrop/common/solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class SolrSchema(object):
'multiValued': True},
{'name': 'annotator', 'type': 'text_en', 'required': False,
'multiValued': True},
{'name': 'publisher', 'type': 'text_en', 'required': False},
{'name': 'pub_place', 'type': 'text_en', 'required': False},
{'name': 'original_pub_info', 'type': 'text_en', 'required': False},
{'name': 'notes', 'type': 'text_en', 'required': False},

{'name': 'text', 'type': 'text_en', 'required': False, 'stored': False,
'multiValued': True},
Expand All @@ -79,7 +83,9 @@ class SolrSchema(object):

]
#: fields to be copied into general purpose text field for searching
text_fields = ['title', 'short_title', 'author', 'pub_year']
text_fields = ['title', 'short_title', 'author', 'pub_year', 'editor',
'translator', 'subject', 'publisher', 'pub_place',
'original_pub_info', 'notes', 'annotator']
#: copy fields, e.g. for facets
copy_fields = [
# ('title', 'title_exact'),
Expand Down

0 comments on commit 93dc1ce

Please sign in to comment.