2011-10-31 15 views
4

誰かがWhooshインデックスに新しいドキュメントを追加するときに奇妙なエラーが発生するのを助けてくれますか?ここでWhooshインデックスに追加する際に奇妙なエラーが発生する

コードです:

def add_to_index(self, doc): 
    ix = index.open_dir(self.index_dir) 
    writer = AsyncWriter(ix) # use async writer to prevent write lock errors 
    writer.add_document(**self.get_doc_args(doc)) 
    writer.commit() 

def get_doc_args(self, doc): 
    return { 
     'id':  u""+str(doc['id']), 
     'org':  doc['org__id'], 
     'created': doc['created_date'], 
     'date':  doc['received_date'], 
     'from_addr': doc['from_addr'], 
     'subject': doc['subject'], 
     'body':  doc['messagebody__cleaned_message'] 
    } 

私は次のエラーを取得する:

TypeError('ord() expected a character, but string of length 0 found',) 
Traceback (most recent call last): 
    File "/usr/local/lib/python2.6/dist-packages/celery/execute/trace.py", line 36, in trace 
    return cls(states.SUCCESS, retval=fun(*args, **kwargs)) 
    File "/usr/local/lib/python2.6/dist-packages/celery/app/task/__init__.py", line 232, in __call__ 
    return self.run(*args, **kwargs) 
    File "/usr/local/lib/python2.6/dist-packages/celery/app/__init__.py", line 172, in run 
    return fun(*args, **kwargs) 
    File "/mnt/deploy/prod/chorus/src/chorus/../chorus/search/__init__.py", line 131, in index_message 
    MessageSearcher().add_to_index(message) 
    File "/mnt/deploy/prod/chorus/src/chorus/../chorus/search/__init__.py", line 29, in add_to_index 
    writer.commit() 
    File "/usr/local/lib/python2.6/dist-packages/whoosh/writing.py", line 423, in commit 
    self.writer.commit(*args, **kwargs) 
    File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filewriting.py", line 501, in commit 
    new_segments = mergetype(self, self.segments) 
    File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filewriting.py", line 78, in MERGE_SMALL 
    reader = SegmentReader(writer.storage, writer.schema, seg) 
    File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filereading.py", line 63, in __init__ 
    self.termsindex = TermIndexReader(tf) 
    File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filetables.py", line 590, in __init__ 
    super(TermIndexReader, self).__init__(dbfile) 
    File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filetables.py", line 502, in __init__ 
    OrderedHashReader.__init__(self, dbfile) 
    File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filetables.py", line 379, in __init__ 
    HashReader.__init__(self, dbfile) 
    File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/filetables.py", line 187, in __init__ 
    self.hashtype = dbfile.read_byte() 
    File "/usr/local/lib/python2.6/dist-packages/whoosh/filedb/structfile.py", line 219, in read_byte 
    return ord(self.file.read(1)) 

不思議なことに、標準ライター(すなわちないAsyncWriter)を使用して、正確に同じコードが正常に動作します。私はここで何が欠けていますか?プロダクションでは、LockErrorsを避けるためにAsyncWriterを使用する必要があることに注意してください。

+0

私は、すべての入力がユニコード文字列であることを確認したはずです。 – kuhnza

答えて

-3

解決策が見つかりました。 Solr :-)

+0

コメントはOKですが、指定したエラーの解決策ではありません。 – n3storm

2

このエラーは、何らかの種類のインデックス破損によって発生します。私の場合、インデックスが再構築されている間、別の理由でマシンがクラッシュしました。

whoosh_indexフォルダの内容を完全に削除し、インデックスを再構築することで簡単に解決できます。

+0

whooshインデックスを削除して再構築すると、それも私のために修正されました。 – Mahn

関連する問題