Return the number of indexed documents

This commit is contained in:
Alexandre Dulaunoy 2014-08-11 14:50:35 +02:00
parent 12dd16daf9
commit f3d1ca052e

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)