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