使用 Unicode 字符进行 Lucene 搜索
我已经对一些文本的数据库建立了索引,并且数据库文本采用 Unicode 编码。 当我使用 Lucene 搜索搜索英语单词时,一切正常。但是,当我使用像“Tuœ”这样的非英语查询时,它会出现以下异常:
Exception in thread "main" org.apache.lucene.queryParser.ParseException: Cannot parse '??': '*' or '?' not allowed as the first character in WildcardQuery
at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:187)
at Search.main(Search.java:151)
Caused by: org.apache.lucene.queryParser.ParseException: '*' or '?' not allowed as first character in WildcardQuery
at org.apache.lucene.queryParser.QueryParser.getWildcardQuery(QueryParser.java:923)
at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1347)
at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1250)
at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1178)
at org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1167)
at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:182)
... 1 more
我应该做什么?
谢谢。
I have indexed a database of some texts and the database texts are of Unicode encoding.
When I search for an English word with Lucene search everything goes OK. But when I use a non-English query like "تو" it gives me the following exception:
Exception in thread "main" org.apache.lucene.queryParser.ParseException: Cannot parse '??': '*' or '?' not allowed as the first character in WildcardQuery
at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:187)
at Search.main(Search.java:151)
Caused by: org.apache.lucene.queryParser.ParseException: '*' or '?' not allowed as first character in WildcardQuery
at org.apache.lucene.queryParser.QueryParser.getWildcardQuery(QueryParser.java:923)
at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1347)
at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1250)
at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1178)
at org.apache.lucene.queryParser.QueryParser.TopLevelQuery(QueryParser.java:1167)
at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:182)
... 1 more
What should I do?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有两点 -
<块引用>
InputStreamReader( new FileInputStream(文件名), "UTF-8");`
Two points here -