Skip to content

Commit

Permalink
Fix Term too long
Browse files Browse the repository at this point in the history
Fixes notanumber#77

Not handling this exception breaks the [re]building the index.
  • Loading branch information
Alir3z4 committed Nov 10, 2015
1 parent b7a1390 commit a249b46
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xapian_backend.py
Expand Up @@ -484,7 +484,12 @@ def add_datetime_to_document(termpos, prefix, term, weight):
document.add_term(document_id)

# finally, replace or add the document to the database
database.replace_document(document_id, document)
try:
database.replace_document(document_id, document)
except xapian.InvalidArgumentError as exc:
if str(exc).startswith('Term too long (> 245)'):
sys.stderr.write('Term too long failure skipped.\n'
'Details """{0}"""\n'.format(str(exc)))

except UnicodeDecodeError:
sys.stderr.write('Chunk failed.\n')
Expand Down

0 comments on commit a249b46

Please sign in to comment.