aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/search.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/search.py b/source/search.py
index d9c8ad59..a9248a09 100644
--- a/source/search.py
+++ b/source/search.py
@@ -110,9 +110,20 @@ def search(term):
results = searcher.search(query, limit=None)
return [(article["feed_id"], article["article_id"]) for article in results]
+def nb_documents():
+ """
+ Return the number of undeleted documents.
+ """
+ try:
+ ix = open_dir(indexdir)
+ except (EmptyIndexError, OSError) as e:
+ raise EmptyIndexError
+ return ix.doc_count()
+
if __name__ == "__main__":
# Point of entry in execution mode.
#create_index()
+ print(nb_documents())
results = search("Nothomb")
for article in results:
print(article)
bgstack15