Skip to content
Snippets Groups Projects
Commit 124768a2e21c authored by Arthur Lutz's avatar Arthur Lutz
Browse files

[views] exact search on code (example with Did & unitid, and cote:search_term)...

[views] exact search on code (example with Did & unitid, and cote:search_term) should go into specific cube
parent 4c406b718a92
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment