diff options
author | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-07-25 09:16:06 +0200 |
---|---|---|
committer | Cédric Bonhomme <kimble.mandel@gmail.com> | 2013-07-25 09:16:06 +0200 |
commit | 3e1cbf9b09702c6be4c7b2d5d800b7fb506bc3a7 (patch) | |
tree | 3e2d320644b6e98bce195f56331e550db8a7a8b6 /source | |
parent | Removed debug print. (diff) | |
download | newspipe-3e1cbf9b09702c6be4c7b2d5d800b7fb506bc3a7.tar.gz newspipe-3e1cbf9b09702c6be4c7b2d5d800b7fb506bc3a7.tar.bz2 newspipe-3e1cbf9b09702c6be4c7b2d5d800b7fb506bc3a7.zip |
Added a function which returns the number of undeleted documents of the Whoosh index.
Diffstat (limited to 'source')
-rw-r--r-- | source/search.py | 11 |
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) |