@@ -65,6 +65,7 @@ public final class MappingParameters {
65
65
static final String FIELD_PARAM_NULL_VALUE = "null_value" ;
66
66
static final String FIELD_PARAM_POSITION_INCREMENT_GAP = "position_increment_gap" ;
67
67
static final String FIELD_PARAM_POSITIVE_SCORE_IMPACT = "positive_score_impact" ;
68
+ static final String FIELD_PARAM_DIMS = "dims" ;
68
69
static final String FIELD_PARAM_SCALING_FACTOR = "scaling_factor" ;
69
70
static final String FIELD_PARAM_SEARCH_ANALYZER = "search_analyzer" ;
70
71
static final String FIELD_PARAM_STORE = "store" ;
@@ -94,6 +95,7 @@ public final class MappingParameters {
94
95
private final NullValueType nullValueType ;
95
96
private final Integer positionIncrementGap ;
96
97
private final boolean positiveScoreImpact ;
98
+ private final Integer dims ;
97
99
private final String searchAnalyzer ;
98
100
private final double scalingFactor ;
99
101
private final Similarity similarity ;
@@ -153,6 +155,8 @@ private MappingParameters(Field field) {
153
155
|| (maxShingleSize >= 2 && maxShingleSize <= 4 ), //
154
156
"maxShingleSize must be in inclusive range from 2 to 4 for field type search_as_you_type" );
155
157
positiveScoreImpact = field .positiveScoreImpact ();
158
+ dims = field .dims ();
159
+ Assert .isTrue (dims <= 2048 , "The maximum number of dimensions that can be in a vector should not exceed 2048." );
156
160
Assert .isTrue (field .enabled () || type == FieldType .Object , "enabled false is only allowed for field type object" );
157
161
enabled = field .enabled ();
158
162
eagerGlobalOrdinals = field .eagerGlobalOrdinals ();
@@ -191,6 +195,8 @@ private MappingParameters(InnerField field) {
191
195
|| (maxShingleSize >= 2 && maxShingleSize <= 4 ), //
192
196
"maxShingleSize must be in inclusive range from 2 to 4 for field type search_as_you_type" );
193
197
positiveScoreImpact = field .positiveScoreImpact ();
198
+ dims = field .dims ();
199
+ Assert .isTrue (dims <= 2048 , "The maximum number of dimensions that can be in a vector should not exceed 2048." );
194
200
enabled = true ;
195
201
eagerGlobalOrdinals = field .eagerGlobalOrdinals ();
196
202
}
@@ -323,6 +329,10 @@ public void writeTypeAndParametersTo(XContentBuilder builder) throws IOException
323
329
builder .field (FIELD_PARAM_POSITIVE_SCORE_IMPACT , positiveScoreImpact );
324
330
}
325
331
332
+ if (dims >= 1 ) {
333
+ builder .field (FIELD_PARAM_DIMS , dims );
334
+ }
335
+
326
336
if (!enabled ) {
327
337
builder .field (FIELD_PARAM_ENABLED , enabled );
328
338
}
0 commit comments