diff options
Diffstat (limited to 'tools2/remove_from_index.py')
-rwxr-xr-x | tools2/remove_from_index.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tools2/remove_from_index.py b/tools2/remove_from_index.py new file mode 100755 index 0000000..a282c2f --- /dev/null +++ b/tools2/remove_from_index.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# remove a article from the index index + +import sys +import config + +input_xml_file_name = config.input_xml_file_name + +sys.path.append('..') +from whoosh.qparser import QueryParser +from whoosh.index import open_dir + + +if len(sys.argv) > 1: + article_title = sys.argv[1] +else: + print "Usage remove_from_index.py article" + +ix = open_dir("index_dir") + +query = QueryParser("title", ix.schema).parse("'%s'" % unicode(article_title)) +ix.delete_by_query(query) +ix.writer().commit() |