diff options
-rw-r--r-- | pyaggr3g470r/search.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/pyaggr3g470r/search.py b/pyaggr3g470r/search.py index f4e57251..a7832c00 100644 --- a/pyaggr3g470r/search.py +++ b/pyaggr3g470r/search.py @@ -114,8 +114,9 @@ def search(user_id, term): raise EmptyIndexError with ix.searcher() as searcher: query = QueryParser("content", ix.schema).parse(term) - results = searcher.search(query, limit=None) - for article in [item for item in results if item["user_id"] == user_id]: + user_doc = Term("user_id", user_id) + results = searcher.search(query, filter=user_doc, limit=None) + for article in results: result_dict[article["feed_id"]].append(article["article_id"]) return result_dict, len(results) @@ -136,4 +137,4 @@ if __name__ == "__main__": print(nb_documents()) results = search("Nothomb") for article in results: - print(article)
\ No newline at end of file + print(article) |