lucene4.5建立索引报错,在整不出来就开除了,谢谢
分词器jar包是paoding-analysis-4.4.0.jar包,在建立索引的时候包错为:
java.lang.IllegalArgumentException: first position increment must be > 0 (got 0) for field 'keyword'
at org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:125)
at org.apache.lucene.index.DocFieldProcessor.processDocument(DocFieldProcessor.java:248)
at org.apache.lucene.index.DocumentsWriterPerThread.updateDocument(DocumentsWriterPerThread.java:254)
at org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:446)
at org.apache.lucene.index.IndexWriter.updateDocument(IndexWriter.java:1551)
at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1221)
at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1202)
at com.artup.search.builder.imageSearch.ImageSearchAllIndexRebuild.index(ImageSearchAllIndexRebuild.java:117)
at com.artup.search.builder.imageSearch.ImageSearchAllIndexRebuild.startCreateIndex(ImageSearchAllIndexRebuild.java:79)
at com.artup.search.thread.CreateLuceneFileThread.run(CreateLuceneFileThread.java:19)
请问是怎么回事?谢谢
------解决方案--------------------把你建立索引的代码贴出来,我看看先
------解决方案--------------------你把错误完整贴上来吧,看不到是哪里报错
------解决方案--------------------没那么难吧,我的个人网站 http://www.ablanxue.com 也是用庖丁解牛做分词器。感觉很好用,中文分词很好。
建立索引代码片段
// 索引
String rootlucene = ServletActionContext.getRequest()
.getRealPath("/lucenexxx/");
File flucene = null;
flucene = new File(rootlucene);
if (flucene.exists()) {
flucene.mkdir();
}
IndexWriter writerlucene = null;
try {
writerlucene = new IndexWriter(rootlucene,
new IKAnalyzer(), false);
} catch (
IOException e) {
// 如果没有索引文件,则创建新索引
writerlucene = new IndexWriter(rootlucene,
new IKAnalyzer(), true);
}
writerlucene.setUseCompoundFile(true);
Document doc1 = null;
doc1 = new Document();
doc1.add(new Field("jianjie", jianjie, Field.Store.YES,
Field.Index.NO, Field.TermVector.NO));
doc1.add(new Field("title", title, Field.Store.YES,
Field.Index.TOKENIZED,
Field.TermVector.WITH_POSITIONS_OFFSETS));
doc1.add(new Field("yearmoth", "" + yearmoth, Field.Store.YES,
Field.Index.NO, Field.TermVector.NO));
doc1.add(new Field("id", "" + id, Field.Store.YES,
Field.Index.TOKENIZED,
Field.TermVector.WITH_POSITIONS_OFFSETS));
doc1.add(new Field("time", time, Fi