/** * Create a new instance configured with the provided FieldType options. See {@link * #DEFAULT_FIELDTYPE}. a field type is used to articulate the desired options (namely * pointValues, docValues, stored). Legacy numerics is configurable this way too. */ public PointVectorStrategy(SpatialContext ctx, String fieldNamePrefix, FieldType fieldType) { super(ctx, fieldNamePrefix); this.fieldNameX = fieldNamePrefix + SUFFIX_X; this.fieldNameY = fieldNamePrefix + SUFFIX_Y; int numPairs = 0; if ((this.hasStored = fieldType.stored())) { numPairs++; } if ((this.hasDocVals = fieldType.docValuesType() != DocValuesType.NONE)) { numPairs++; } if ((this.hasPointVals = fieldType.pointDimensionCount() > 0)) { numPairs++; } if (fieldType.indexOptions() != IndexOptions.NONE && fieldType.numericType() != null) { if (hasPointVals) { throw new IllegalArgumentException( "pointValues and LegacyNumericType are mutually exclusive"); } if (fieldType.numericType() != FieldType.LegacyNumericType.DOUBLE) { throw new IllegalArgumentException( getClass() + " does not support " + fieldType.numericType()); } numPairs++; legacyNumericFieldType = new FieldType(LegacyDoubleField.TYPE_NOT_STORED); legacyNumericFieldType.setNumericPrecisionStep(fieldType.numericPrecisionStep()); legacyNumericFieldType.freeze(); } else { legacyNumericFieldType = null; } this.fieldsLen = numPairs * 2; }
/** * Expert: sets the token stream to be used for indexing and causes isIndexed() and isTokenized() * to return true. May be combined with stored values from stringValue() or getBinaryValue() */ public void setTokenStream(TokenStream tokenStream) { if (!type.indexed() || !type.tokenized()) { throw new IllegalArgumentException("TokenStream fields must be indexed and tokenized"); } if (type.numericType() != null) { throw new IllegalArgumentException("cannot set private TokenStream on numeric fields"); } this.tokenStream = tokenStream; }
/** Create a new mutable FieldType with all of the properties from <code>ref</code> */ public FieldType(FieldType ref) { this.indexed = ref.indexed(); this.stored = ref.stored(); this.tokenized = ref.tokenized(); this.storeTermVectors = ref.storeTermVectors(); this.storeTermVectorOffsets = ref.storeTermVectorOffsets(); this.storeTermVectorPositions = ref.storeTermVectorPositions(); this.storeTermVectorPayloads = ref.storeTermVectorPayloads(); this.omitNorms = ref.omitNorms(); this.indexOptions = ref.indexOptions(); this.docValueType = ref.docValueType(); this.numericType = ref.numericType(); // Do not copy frozen! }