我有同樣的問題,所以我只是簡單地創建了自己的領域:
public class VecTextField extends Field {
/* Indexed, tokenized, not stored. */
public static final FieldType TYPE_NOT_STORED = new FieldType();
/* Indexed, tokenized, stored. */
public static final FieldType TYPE_STORED = new FieldType();
static {
TYPE_NOT_STORED.setIndexed(true);
TYPE_NOT_STORED.setTokenized(true);
TYPE_NOT_STORED.setStoreTermVectors(true);
TYPE_NOT_STORED.setStoreTermVectorPositions(true);
TYPE_NOT_STORED.freeze();
TYPE_STORED.setIndexed(true);
TYPE_STORED.setTokenized(true);
TYPE_STORED.setStored(true);
TYPE_STORED.setStoreTermVectors(true);
TYPE_STORED.setStoreTermVectorPositions(true);
TYPE_STORED.freeze();
}
// TODO: add sugar for term vectors...?
/** Creates a new TextField with Reader value. */
public VecTextField(String name, Reader reader, Store store) {
super(name, reader, store == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
}
/** Creates a new TextField with String value. */
public VecTextField(String name, String value, Store store) {
super(name, value, store == Store.YES ? TYPE_STORED : TYPE_NOT_STORED);
}
/** Creates a new un-stored TextField with TokenStream value. */
public VecTextField(String name, TokenStream stream) {
super(name, stream, TYPE_NOT_STORED);
}
}
希望這有助於