Example #1
0
 /**
  * NOTE: this method does not carry over termVector booleans nor docValuesType; the indexer
  * chain (TermVectorsConsumerPerField, DocFieldProcessor) must set these fields when they
  * succeed in consuming the document
  */
 public FieldInfo addOrUpdate(String name, IndexableFieldType fieldType) {
   // TODO: really, indexer shouldn't even call this
   // method (it's only called from DocFieldProcessor);
   // rather, each component in the chain should update
   // what it "owns".  EG fieldType.indexOptions() should
   // be updated by maybe FreqProxTermsWriterPerField:
   return addOrUpdateInternal(
       name,
       -1,
       fieldType.indexed(),
       false,
       fieldType.omitNorms(),
       false,
       fieldType.indexOptions(),
       fieldType.docValueType(),
       null);
 }
 @BeforeClass
 public static void beforeClass() throws Exception {
   testDoc = new Document();
   fieldInfos = new FieldInfos.Builder();
   DocHelper.setupDoc(testDoc);
   for (IndexableField field : testDoc.getFields()) {
     FieldInfo fieldInfo = fieldInfos.getOrAdd(field.name());
     IndexableFieldType ift = field.fieldType();
     fieldInfo.setIndexOptions(ift.indexOptions());
     if (ift.omitNorms()) {
       fieldInfo.setOmitsNorms();
     }
     fieldInfo.setDocValuesType(ift.docValuesType());
   }
   dir = newDirectory();
   IndexWriterConfig conf =
       newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy());
   conf.getMergePolicy().setNoCFSRatio(0.0);
   IndexWriter writer = new IndexWriter(dir, conf);
   writer.addDocument(testDoc);
   writer.close();
 }