Skip to content

Commit 19160c4

Browse files
committed
Fix handling of edition-only fields
1 parent 81e3c0e commit 19160c4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

openlibrary/plugins/worksearch/schemes/editions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class EditionSearchScheme(SearchScheme):
3131
"publish_year",
3232
"language",
3333
"publisher_facet",
34+
"acquisition",
3435
}
3536
)
3637
non_solr_fields = frozenset()

openlibrary/plugins/worksearch/schemes/works.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import infogami
1414
from openlibrary.plugins.upstream.utils import convert_iso_to_marc
1515
from openlibrary.plugins.worksearch.schemes import SearchScheme
16+
from openlibrary.plugins.worksearch.schemes.editions import EditionSearchScheme
1617
from openlibrary.solr.query_utils import (
1718
EmptyTreeError,
1819
fully_escape_query,
@@ -238,9 +239,15 @@ class WorkSearchScheme(SearchScheme):
238239

239240
def is_search_field(self, field: str):
240241
# New variable introduced to prevent rewriting the input.
241-
if field.startswith(('work.', 'edition.')):
242+
if field.startswith('work.'):
242243
return self.is_search_field(field.partition(".")[2])
243-
return super().is_search_field(field) or field.startswith('id_')
244+
if field.startswith('edition.'):
245+
return EditionSearchScheme().is_search_field(field.partition(".")[2])
246+
return (
247+
super().is_search_field(field)
248+
or field.startswith('id_')
249+
or EditionSearchScheme().is_search_field(field)
250+
)
244251

245252
def transform_user_query(
246253
self, user_query: str, q_tree: luqum.tree.Item

0 commit comments

Comments
 (0)