简体   繁体   English

lucene Field.Index.ANALYZED在inVersion.LUCENE_40中不起作用

[英]lucene Field.Index.ANALYZED not working inVersion.LUCENE_40

I am new for lucene i want indexing and searching filename an url give any possible answer. 我是Lucene的新手,我想索引和搜索URL的文件名给出任何可能的答案。

My code as following: 我的代码如下:

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();

but at run time exception will come: 但是在运行时会出现异常:

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)

This isn't related to Lucene. 这与Lucene无关。 You have some runtime error. 您有一些运行时错误。 The AbstractMethodError method error javadoc states: 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.

Have a look at the libraries you're using when running the application. 在运行应用程序时查看正在使用的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM