blob: a282c2fe8e0cefaf9aaf06ec99a2fffbe875c602 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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()
|