2012-01-13 38 views
1

你好,大家好我目前解析所有的HTML體 查找包含單詞 列表的文檔頻率,爲什麼我不斷收到此錯誤爲什麼我一直在查詢分析器收到錯誤使用Lucene時

org.apache.lucene.queryParser.ParseException: Cannot parse '': Encountered "<EOF>" at line 1, column 0. 

期待之一: ... 「+」 ... 「 - 」 ...... 「(」 ... 「」 ... ... ... ... ... 「[」 ...... 「{」 ... ... ... 「」 ......

at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:211) 
at CalculateWeightTable.search(CalculateWeightTable.java:221) 
at CalculateWeightTable.calculate(CalculateWeightTable.java:134) 
at FocusedCrawlingMain.Search(FocusedCrawlingMain.java:64) 
at View.actionPerformed(View.java:219) 
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) 
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) 
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) 
at javax.swing.DefaultButtonModel.setPressed(Unknown Source) 
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) 
at java.awt.Component.processMouseEvent(Unknown Source) 
at javax.swing.JComponent.processMouseEvent(Unknown Source) 
at java.awt.Component.processEvent(Unknown Source) 
at java.awt.Container.processEvent(Unknown Source) 
at java.awt.Component.dispatchEventImpl(Unknown Source) 
at java.awt.Container.dispatchEventImpl(Unknown Source) 
at java.awt.Component.dispatchEvent(Unknown Source) 
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) 
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) 
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) 
at java.awt.Container.dispatchEventImpl(Unknown Source) 
at java.awt.Window.dispatchEventImpl(Unknown Source) 
at java.awt.Component.dispatchEvent(Unknown Source) 
at java.awt.EventQueue.dispatchEventImpl(Unknown Source) 
at java.awt.EventQueue.access$000(Unknown Source) 
at java.awt.EventQueue$1.run(Unknown Source) 
at java.awt.EventQueue$1.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) 
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) 
at java.awt.EventQueue$2.run(Unknown Source) 
at java.awt.EventQueue$2.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) 
at java.awt.EventQueue.dispatchEvent(Unknown Source) 
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
at java.awt.EventDispatchThread.run(Unknown Source) 

,這是我發現的文檔頻率

代碼它說,當了Lucene嘗試解析查詢字符串

這是在我的代碼本節中的錯誤是

Query query = parser.parse(queryString); 

我不知道爲什麼它不斷給我的錯誤在解析查詢字符串

private static int search(Searcher searcher, String queryString) 
     throws ParseException, IOException { 

    // Build a Query object 
    StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT); 
    QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, "content", 
      analyzer); 
    Query query = parser.parse(queryString); 

    // Search for the query 
    TopScoreDocCollector collector = TopScoreDocCollector.create(10, true); 
    searcher.search(query, collector); 

    ScoreDoc[] hit = collector.topDocs().scoreDocs; 

    int hitsCount = hit.length; 

    if (hitsCount == 0) { 
     //System.out.println("No matches were found for \"" + queryString+ "\""); 
    } else { 
     //System.out.println("hit count : " + collector.getTotalHits()); 

    } 

    return collector.getTotalHits(); 
} 

回答

2

貌似的queryString對象爲空。你能從它被調用的地方檢查這個方法的輸入嗎?

+0

啊是非常空的tq。 我以爲這是解析器無法解析特殊字符。所以我很困惑爲什麼。好的tq btw – Carlo 2012-01-13 06:22:13

相關問題