From 860030540c8df782f3e550a911a9ba6d7d51de71 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Mon, 24 Jun 2013 21:35:56 +0200 Subject: Integration of the new search module. --- source/pyAggr3g470r.py | 6 +++++- source/search.py | 2 +- source/static/templates/search.html | 3 +-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index f065b871..4f006571 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -169,7 +169,11 @@ class pyAggr3g470r(object): feed_id = None if param == "Feed": feed_id, _, query = value.partition(':') - search_result = self.mongo.full_search(param) + search_result = defaultdict(list) + results = search.search(param) + for result in results: + article = self.mongo.get_articles(result[0], result[1]) + search_result[result[0]].append(article) tmpl = lookup.get_template("search.html") return tmpl.render(search_result=search_result, query=query, feed_id=feed_id, mongo=self.mongo) diff --git a/source/search.py b/source/search.py index 218d2436..2b0fea85 100644 --- a/source/search.py +++ b/source/search.py @@ -71,7 +71,7 @@ def search(term): with ix.searcher() as searcher: query = QueryParser("content", ix.schema).parse(term) results = searcher.search(query) - return [article['title'] for article in results] + return [(article["feed_id"], article["article_id"]) for article in results] if __name__ == "__main__": # Point of entry in execution mode. diff --git a/source/static/templates/search.html b/source/static/templates/search.html index da766ee9..9a635935 100644 --- a/source/static/templates/search.html +++ b/source/static/templates/search.html @@ -5,7 +5,7 @@ import utils %>
%if len(search_result) != 0: -

Articles containing the string ${query} (${sum([articles.count() for articles in search_result.values()])} results)

+

Articles containing the string ${query} (${sum([len(articles) for articles in search_result.values()])} results)

%else:

String ${query} not found.

%endif @@ -18,7 +18,6 @@ import utils <% new_feed_section = True feed = mongo.get_feed(feed_id) - print(search_result[feed["feed_id"]].count()) for article in search_result[feed["feed_id"]]: if new_feed_section is True: new_feed_section = False -- cgit