日期:2014-05-16  浏览次数:20701 次

lucene3.5报错org.apache.lucene.queryParser.ParseException
org.apache.lucene.queryParser.ParseException: Encountered "<EOF>" at line 1, column 0.
Was expecting one of:
    <NOT> ...
    "+" ...
    "-" ...
    "(" ...
    "*" ...
    <QUOTED> ...
    <TERM> ...
    <PREFIXTERM> ...
    <WILDTERM> ...
    "[" ...
    "{" ...
    <NUMBER> ...
    <TERM> ...
    "*" ...
    
at org.apache.lucene.queryParser.QueryParser.generateParseException(QueryParser.java:1818)
at org.apache.lucene.queryParser.QueryParser.jj_consume_token(QueryParser.java:1700)
at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1327)
at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1237)
at com.mylucene.test.TestLucene.search(TestLucene.java:107)
at com.mylucene.test.TestLucene.main(TestLucene.java:141): Encountered "<EOF>" at line 1, column 0.
Was expecting one of:
    <NOT> ...
    "+" ...
    "-" ...
    "(" ...
    "*" ...
    <QUOTED> ...
    <TERM> ...
    <PREFIXTERM> ...
    <WILDTERM> ...
    "[" ...
    "{" ...
    <NUMBER> ...
    <TERM> ...
    "*" ...
    
at org.apache.lucene.queryParser.QueryParser.generateParseException(QueryParser.java:1818)
at org.apache.lucene.queryParser.QueryParser.jj_consume_token(QueryParser.java:1700)
at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:1327)
at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:1237)
at com.mylucene.test.TestLucene.search(TestLucene.java:107)

at com.mylucene.test.TestLucene.main(TestLucene.java:141)

解决办法:

Query query = parser.Query("hadoop");

改为

Query query = parser.parse("hadoop");