Skip to content

Instantly share code, notes, and snippets.

@daramcq
Created October 9, 2013 22:18
Show Gist options
  • Save daramcq/6909481 to your computer and use it in GitHub Desktop.
Save daramcq/6909481 to your computer and use it in GitHub Desktop.
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