Permalink
Browse files

Fixed a bug in subject filtering.

  • Loading branch information...
1 parent f20b79b commit f94764358166665520910957603d9db92def3921 Anand Chitipothu committed Dec 31, 2013
Showing with 5 additions and 3 deletions.
  1. +5 −3 openlibrary/core/loanstats.py
@@ -49,7 +49,7 @@ def solr_select(self, params):
params['fq'].append("ia_collections_id:" + self.solrescape(self.collection))
if self.subject:
- params['fq'].append(self._get_subject_filter(self.solrescape(self.subject)))
+ params['fq'].append(self._get_subject_filter(self.subject))
if self.time_period:
start, end = self.time_period
@@ -72,12 +72,14 @@ def solrescape(self, text):
return re_solrescape.sub(r'\\\1', text)
def _get_subject_filter(self, subject):
+ # subjects are stored as subject_key field as values like:
+ # ["subject:fiction", "subject:history", "place:england"]
+ # etc.
if ":" in subject:
type, subject = subject.split(":", 1)
else:
type = "subject"
- key = type + "_key"
- return "%s:%s" % (key, subject)
+ return "subject_key:%s\\:%s" % (type, self.solrescape(subject))
def solr_select_facet(self, facet_field):
facet_counts = self._get_all_facet_counts()

0 comments on commit f947643

Please sign in to comment.