Return the number of indexed documents

pull/11/head
Alexandre Dulaunoy 2014-08-11 14:50:35 +02:00
parent 12dd16daf9
commit f3d1ca052e
1 changed files with 6 additions and 0 deletions

View File

@ -24,6 +24,7 @@ indexertype = cfg.get("Indexer", "type")
argParser = argparse.ArgumentParser(description='Fulltext search for AIL')
argParser.add_argument('-q', action='append', help='query to lookup (one or more)')
argParser.add_argument('-n', action='store_true', default=False, help='Return numbers of document indexed')
args = argParser.parse_args()
from whoosh import index
@ -33,6 +34,11 @@ schema = Schema(title=TEXT(stored=True), path=ID(stored=True), content=TEXT)
ix = index.open_dir(indexpath)
from whoosh.qparser import QueryParser
if args.n:
print ix.doc_count_all()
exit(0)
if args.q is None:
argParser.print_help()
exit(1)