Commit 681975c0 authored by Dennis Baurichter's avatar Dennis Baurichter

Improve web search

 * Also match against exam date.
 * Allow searching multiple fields (e.g. lecture and examiner).

Fixes #96
Fixes #77
parent 1eab7dcd
......@@ -104,13 +104,14 @@ class ExistingFilter:
return s._cache
## \brief Intermediate filter for exam search engines, passing only results that
# have a field matching the search query.
## \brief Intermediate filter for exam search engines, passing only results
# where the fields match the search query.
#
# To filter results, first all aliases are gathered that match the search
# argument using the aliases.Aliases.fuzzyMatch method.
# The resulting list of aliases is then used to filter the results by discarding
# anything that does not have at least one alias in its name.
# For each exam a string describing it is build.
# This string contains all aliases for its lectures and examiners, as well as
# its date and folder name.
# That string is then matched against the query using the
# search.util.SESearcher.match method.
#
# \param input List of #exam_t instances
# \returns List of #exam_t instances
......@@ -141,25 +142,27 @@ class NameFilter:
if searchName=="":
return allItems
res=set()
searcher=util.SESearcher(searchName)
lectures=s._aliases.lectures.fuzzyMatchExpand(searcher)
examiners=s._aliases.examiners.fuzzyMatchExpand(searcher)
instances=s._folders.fuzzyMatch(searcher)
res=set()
lectures_map = s._aliases.lectures.primary_map
examiners_map = s._aliases.examiners.primary_map
def process(item):
item_descr_str = item.folder.display_title + " " + item.name.date
for lecture in item.name.lectures:
if lecture in lectures:
res.add(item)
return
if lecture in lectures_map:
item_descr_str += " " + " ".join(lectures_map[lecture])
else:
item_descr_str += " " + lecture
for examiner in item.name.examiners:
if examiner in examiners:
res.add(item)
return
if item.folder.display_title in instances:
if examiner in examiners_map:
item_descr_str += " " + " ".join(examiners_map[examiner])
else:
item_descr_str += " " + examiner
if searcher.match(item_descr_str):
res.add(item)
return
for item in allItems:
process(item)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment