Enum Constant and Description |
---|
DOCS_AND_FREQS
Only documents and term frequencies are indexed: positions are omitted.
|
DOCS_AND_FREQS_AND_POSITIONS
Indexes documents, frequencies and positions.
|
DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS
Indexes documents, frequencies, positions and offsets.
|
DOCS_ONLY
Only documents are indexed: term frequencies and positions are omitted.
|
Project: languagetool File: EmptyLuceneIndexCreator.java View source code | 6 votes | ![]() ![]() |
public static void main(String[] args) throws IOException {
if (args.length != 1) {
System.out.println("Usage: " + EmptyLuceneIndexCreator.class.getSimpleName() + " <indexPath>");
System.exit(1);
}
Analyzer analyzer = new StandardAnalyzer();
IndexWriterConfig config = new IndexWriterConfig(analyzer);
Directory directory = FSDirectory.open(new File(args[0]).toPath());
IndexWriter writer = new IndexWriter(directory, config);
FieldType fieldType = new FieldType();
fieldType.setIndexOptions(IndexOptions.DOCS);
fieldType.setStored(true);
Field countField = new Field("totalTokenCount", String.valueOf(0), fieldType);
Document doc = new Document();
doc.add(countField);
writer.addDocument(doc);
writer.close();
}
lucene IndexOptions可以设置DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS DOCS,ES里也可以设置
原文:http://www.cnblogs.com/bonelee/p/6397455.html