I was stumped on this for awhile. The other answers here are helpful but even with them, the situation was not obvious to me. So after the light finally went on for me I decided to add this additional answer to make things a bit clearer for the next person.
The reason that the Field
signature that supports term vectors is depreciated is because it utilizes the Field.TermVector enum
which is depreciated as of Lucene 4.0.
In Lucene 4.0, a new method signature was added to the Field
class that supports passing a FieldType
instead. The FieldType
class is more flexible than the old enum
approach and provides the ability to set even more Field options then were previously available.
Here is an example of how to create a Text field, not stored, that supports term vectors by passing a FieldType
object when instantiating a Field
object.
FieldType specialTextFieldType = new FieldType(TextField.TYPE_NOT_STORED);
specialTextFieldType.StoreTermVectors = true;
Document exampleDoc = new Document();
exampleDoc.Add(new Field("SomeField", someData, specialTextFieldType ));