Skip to content

Commit

Permalink
Fix publishers pages showing no books
Browse files Browse the repository at this point in the history
  • Loading branch information
cdrini committed Jan 4, 2023
1 parent 347f4a1 commit ed47d57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions openlibrary/plugins/worksearch/subjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def get_subject(
'q': query_dict_to_str(
{meta.facet_key: self.normalize_key(meta.path)},
unescaped=unescaped_filters,
phrase=True,
),
**filters,
},
Expand Down
8 changes: 7 additions & 1 deletion openlibrary/solr/query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def query_dict_to_str(
escaped: dict | None = None,
unescaped: dict | None = None,
op: Literal['AND', 'OR', ''] = '',
phrase: bool = False,
) -> str:
"""
Converts a query dict to a search query.
Expand All @@ -246,11 +247,16 @@ def query_dict_to_str(
'title:(foo \\\\? to escape)'
>>> query_dict_to_str({'title': 'YES AND'})
'title:(YES and)'
>>> query_dict_to_str({'publisher_facet': 'Running Press'}, phrase=True)
'publisher_facet:"Running Press"'
"""
result = ''
if escaped:
result += f' {op} '.join(
f'{k}:({fully_escape_query(v)})' for k, v in escaped.items()
f'{k}:"{fully_escape_query(v)}"'
if phrase
else f'{k}:({fully_escape_query(v)})'
for k, v in escaped.items()
)
if unescaped:
if result:
Expand Down

0 comments on commit ed47d57

Please sign in to comment.