Skip to content

Commit

Permalink
refs #116 - filter by language even if there is no text
Browse files Browse the repository at this point in the history
  • Loading branch information
johnscancella committed Apr 9, 2018
1 parent 2d996fa commit 252fd1c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ def get_titles_from_solr_documents(solr_response):
title = models.Title.objects.get(lccn=lccn)
results.append(title)
except models.Title.DoesNotExist, e:
pass # TODO: log exception
LOGGER.error("Title does not exist!", e)
pass
return results


Expand Down Expand Up @@ -392,8 +393,6 @@ def page_search(d):
if d.get('lccn', None):
q.append(query_join(d.getlist('lccn'), 'lccn'))



if d.get('state', None):
q.append(query_join(d.getlist('state'), 'state'))

Expand All @@ -410,6 +409,11 @@ def page_search(d):
ocrs = ['ocr_%s' % l for l in settings.SOLR_LANGUAGES]

lang = d.get('language', None)

lang_full = models.Language.objects.get(code=str(lang)) if lang else None
if lang_full:
q.append('+language:%s' % lang_full)

ocr_lang = 'ocr_' + lang if lang else 'ocr'
if d.get('ortext', None):
q.append('+((' + query_join(solr_escape(d['ortext']).split(' '), "ocr"))
Expand Down Expand Up @@ -457,7 +461,10 @@ def page_search(d):
q.append(')')
if d.get('sequence', None):
q.append('+sequence:"%s"' % d['sequence'])
return ' '.join(q)

solr_query = ' '.join(q)
LOGGER.debug("Solr query is [%s]", solr_query)
return solr_query

def query_join(values, field, and_clause=False):
"""
Expand Down

0 comments on commit 252fd1c

Please sign in to comment.