Commit aa3f1c7f authored by Gijs Hendriksen's avatar Gijs Hendriksen

Clean up bulk index code and add necessary documentation

parent f5b6672a
This diff is collapsed.
......@@ -7,12 +7,19 @@ from search import Search
def bulk_index(args: argparse.Namespace):
"""
Runs the `index` command, which reads a JSON file of documents and indexes them
"""
index = Index.get_index(args.engine, args.database)
filename = args.input
index.bulk_index(filename)
def query_index(args: argparse.Namespace):
"""
Runs the `query` command, which queries an existing index using a specific set of query terms
"""
index = Index.get_index(args.engine, args.database)
query_terms = args.terms
......@@ -23,6 +30,11 @@ def query_index(args: argparse.Namespace):
def benchmark(args: argparse.Namespace):
"""
Runs the `benchmark` command, which runs several predefined queries against a DuckDB and a MonetDB index,
to compare the differences in query time.
"""
duckdb_index = DuckDBIndex(args.duckdb)
monetdb_index = MonetDBIndex(args.monetdb)
......@@ -50,7 +62,6 @@ def benchmark(args: argparse.Namespace):
for i, index in enumerate(indices):
index.clear()
print('Indexing...')
index.bulk_index(filename)
search = Search(index)
......@@ -88,11 +99,17 @@ def benchmark(args: argparse.Namespace):
def dump_index(args: argparse.Namespace):
"""
Runs the `dump` command, which prints the contents of an index
"""
index = Index.get_index(args.engine, args.database)
print(index)
def clear_index(args: argparse.Namespace):
"""
Runs the `clear` command, which removes the contents of an index
"""
index = Index.get_index(args.engine, args.database)
index.clear()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment