求助:代码如下,
import java.io.IOException;import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.analysis.standard.StandardAnalyzer;public class text1 {
public static void main(String[] args) throws CorruptIndexException,
IOException {
String indexPath = "index"; // IndexWriter
IndexWriter writer; writer = new IndexWriter(indexPath, new StandardAnalyzer()); // Document
Document doc = new Document(); // Field -title
String title = "i love china";
Field field = new Field("title", title, Field.Store.YES,
Field.Index.TOKENIZED);
// add field
doc.add(field); // Field -content
String content = "i love you, my mother land! ";
field = new Field("content", content, Field.Store.YES,
Field.Index.TOKENIZED);
// add field
doc.add(field); // add document
writer.addDocument(doc); // close IndexWriter
writer.close(); // message
System.out.println("Index Created!");
}
}
编译后居然来了个莫名其妙的错误:ERROR: index path not specifiedUsage: java org.apache.lucene.index.CheckIndex pathToIndex [-fix] [-segment X] [-segment Y] -fix: actually write a new segments_N file, removing any problematic segments
-segment X: only check the specified segments. This can be specified multiple
times, to check more than one segment, eg '-segment _2 -segment _a'.
You can't use this with the -fix option**WARNING**: -fix should only be used on an emergency basis as it will cause
documents (perhaps many) to be permanently removed from the index. Always make
a backup copy of your index before running this! Do not run this tool on an index
that is actively being written to. You have been warned!Run without -fix, this tool will open the index, report version information
and report any exceptions it hits and what action it would take if -fix were
specified. With -fix, this tool will remove any segments that have issues and
write a new segments_N file. This means all documents contained in the affected
segments will be removed.This tool exits with exit code 1 if the index cannot be opened or has any
corruption, else 0.请高手指点。。
import java.io.IOException;import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.analysis.standard.StandardAnalyzer;public class text1 {
public static void main(String[] args) throws CorruptIndexException,
IOException {
String indexPath = "index"; // IndexWriter
IndexWriter writer; writer = new IndexWriter(indexPath, new StandardAnalyzer()); // Document
Document doc = new Document(); // Field -title
String title = "i love china";
Field field = new Field("title", title, Field.Store.YES,
Field.Index.TOKENIZED);
// add field
doc.add(field); // Field -content
String content = "i love you, my mother land! ";
field = new Field("content", content, Field.Store.YES,
Field.Index.TOKENIZED);
// add field
doc.add(field); // add document
writer.addDocument(doc); // close IndexWriter
writer.close(); // message
System.out.println("Index Created!");
}
}
编译后居然来了个莫名其妙的错误:ERROR: index path not specifiedUsage: java org.apache.lucene.index.CheckIndex pathToIndex [-fix] [-segment X] [-segment Y] -fix: actually write a new segments_N file, removing any problematic segments
-segment X: only check the specified segments. This can be specified multiple
times, to check more than one segment, eg '-segment _2 -segment _a'.
You can't use this with the -fix option**WARNING**: -fix should only be used on an emergency basis as it will cause
documents (perhaps many) to be permanently removed from the index. Always make
a backup copy of your index before running this! Do not run this tool on an index
that is actively being written to. You have been warned!Run without -fix, this tool will open the index, report version information
and report any exceptions it hits and what action it would take if -fix were
specified. With -fix, this tool will remove any segments that have issues and
write a new segments_N file. This means all documents contained in the affected
segments will be removed.This tool exits with exit code 1 if the index cannot be opened or has any
corruption, else 0.请高手指点。。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货