Created
October 9, 2013 22:18
-
-
Save daramcq/6909481 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import xapian | |
import string | |
from config_file import * | |
def indexThread(thread_id, content): | |
try: | |
# Open the database for update, creating a new database if necessary. | |
database = xapian.WritableDatabase(db_global, xapian.DB_CREATE_OR_OPEN) | |
indexer = xapian.TermGenerator() | |
stemmer = xapian.Stem("english") | |
indexer.set_stemmer(stemmer) | |
try: | |
doc = xapian.Document() | |
doc.set_data(content) | |
doc.add_value(id_global, thread_id) | |
indexer.set_document(doc) | |
indexer.index_text(content) | |
database.add_document(doc) | |
except Exception as e: | |
print(str(e)) | |
except Exception, e: | |
print >> sys.stderr, "Exception: %s" % str(e) | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment