diff --git a/views.py b/views.py index 4c406b718a92546a3ba2cf2a93e0eb7704380978_dmlld3MucHk=..124768a2e21caa7bd127293f2865439100817faf_dmlld3MucHk= 100644 --- a/views.py +++ b/views.py @@ -44,8 +44,8 @@ class CWFacetedSearch(FacetedSearch): # fields that should be searched - fields = ["title^3", "name^3", "content^2", 'content', '_all'] + fields = ["unitid^6", "title^3", "unittitle^3", "name^3", "content^2", 'content', '_all'] facets = { # use bucket aggregations to define facets 'cw_etype': TermsFacet(field='cw_etype'), @@ -48,7 +48,8 @@ facets = { # use bucket aggregations to define facets 'cw_etype': TermsFacet(field='cw_etype'), + 'unitid': TermsFacet(field='unitid'), 'creation_date': DateHistogramFacet(field='creation_date', interval='month'), 'commemoration_year': DateHistogramFacet(field='commemoration_year', interval='year'), 'year': DateHistogramFacet(field='year', interval='year'), @@ -98,6 +99,9 @@ start = (max(int(value) - 1, 0)) * 10 stop = start + 10 indexable = indexable_types(self._cw.vreg.schema) + if query_string.startswith('cote:'): + query_string = query_string.split(':')[1] + facet_selections['unitid'] = query_string search = CWFacetedSearch(query_string, facet_selections, doc_types=indexable)[start:stop] @@ -120,5 +124,6 @@ infos = result.to_dict() infos['_score'] = result.meta.score infos['keys'] = result.to_dict().keys() - infos.setdefault('title', infos.get('name', infos.get('reference', u'n/a'))) + infos['url'] = infos['cwuri'].startswith('_auto_generated') and infos['eid'] or infos['cwuri'] + infos.setdefault('title', infos.get('name', infos.get('reference', infos.get('unittitle', u'n/a')))) try: @@ -124,5 +129,5 @@ try: - self.w(u'<a href="%(cwuri)s">%(title)s</a> (%(_score).2f)<br/>' % (infos)) + self.w(u'<a href="%(url)s">%(title)s</a> (%(_score).2f)<br/>' % (infos)) if self._cw.form.get('debug-es'): self.w(u' [%(keys)s] <br/>' % infos) except KeyError: