[英]lucene Field.Index.ANALYZED not working inVersion.LUCENE_40
我是Lucene的新手,我想索引和搜索URL的文件名給出任何可能的答案。
我的代碼如下:
IndexWriter writer = null;
Analyzer analyzer = new StandardAnalyzer();
FSDirectory dir = FSDirectory.open(index);
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer);
writer = new IndexWriter(dir, config);
Document doc = new Document();
doc.add(new Field("file_name", rs.getString("file_name"), Field.Store.NO,Field.Index.ANALYZED));
writer.addDocument(doc);
writer.optimize();
writer.commit();
writer.close();
但是在運行時會出現異常:
Exception in thread "main" java.lang.AbstractMethodError: org.apache.lucene.analysis.TokenStream.incrementToken()Z
at org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:133)
at org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFieldProcessorPerThread.java:248)
at org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:851)
at org.apache.lucene.index.DocumentsWriter.addDocument(DocumentsWriter.java:827)
at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:2022)
at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1996)
at TextIndex1.main(TextIndex1.java:63)
這與Lucene無關。 您有一些運行時錯誤。 javadoc的AbstractMethodError
方法錯誤指出:
Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last compiled.
在運行應用程序時查看正在使用的庫。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.