Does whoosh require all strings to be unicode?

孤者浪人 提交于 2019-12-14 03:53:07

问题


I am redoing my search app in Whoosh from Solr. I am now learning from the quick start. But I kept running into problems each time I had to deal with strings

>>>writer.add_document(iden=fil, content=F2T.file_to_text(fil_path)) ValueError: 'File Name.doc' is not unicode or sequence

and then:

>>>query = QueryParser("content", ix.schema).parse("first")
AssertionError: 'first' is not unicode

And THAT line comes straight from the quick-start turorial! Does Whoosh require all fields to be in unicode? It will be real hard work to make my app unicode-aware (and its not even worth it). As for "not unicode or sequence", I understand that string is also a sequence data type.


回答1:


Yes, it requires strings are in Unicode.

 query = QueryParser("content", ix.schema).parse("first")

Change that to:

query = QueryParser("content", ix.schema).parse(u"first")


来源:https://stackoverflow.com/questions/6897042/does-whoosh-require-all-strings-to-be-unicode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!