aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/search.py
diff options
context:
space:
mode:
authorCédric Bonhomme <kimble.mandel@gmail.com>2013-11-12 22:52:04 +0100
committerCédric Bonhomme <kimble.mandel@gmail.com>2013-11-12 22:52:04 +0100
commite73be6cf40b50173753a65f6596eb582b1e072ea (patch)
tree626ac450a0cc22c2c12c6dee38c842a4eeaf9308 /pyaggr3g470r/search.py
parentResized search form. (diff)
downloadnewspipe-e73be6cf40b50173753a65f6596eb582b1e072ea.tar.gz
newspipe-e73be6cf40b50173753a65f6596eb582b1e072ea.tar.bz2
newspipe-e73be6cf40b50173753a65f6596eb582b1e072ea.zip
Article searching with Whoosh OK.
Diffstat (limited to 'pyaggr3g470r/search.py')
-rw-r--r--pyaggr3g470r/search.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/pyaggr3g470r/search.py b/pyaggr3g470r/search.py
index 9fd67124..56aef3f6 100644
--- a/pyaggr3g470r/search.py
+++ b/pyaggr3g470r/search.py
@@ -34,6 +34,7 @@ from whoosh.fields import *
from whoosh.query import *
from whoosh.qparser import QueryParser
from whoosh.writing import AsyncWriter
+from collections import defaultdict
import conf
import utils
@@ -101,6 +102,7 @@ def search(term):
Search for `term` in the index.
Returns a list of articles.
"""
+ result_dict = defaultdict(list)
try:
ix = open_dir(indexdir)
except (EmptyIndexError, OSError) as e:
@@ -108,7 +110,9 @@ def search(term):
with ix.searcher() as searcher:
query = QueryParser("content", ix.schema).parse(term)
results = searcher.search(query, limit=None)
- return [(article["feed_id"], article["article_id"]) for article in results]
+ for article in results:
+ result_dict[article["feed_id"]].append(article["article_id"])
+ return result_dict
def nb_documents():
"""
bgstack15