Skip to content

Commit e593f17

Browse files
committed
don't explicitly set the config if not present
1 parent 832fe45 commit e593f17

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

server/src/main/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapper.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,10 @@ private static SparseVectorFieldMapper.IndexOptions getDefaultIndexOptions(Mappi
144144
return new IndexOptions(false, null);
145145
}
146146

147-
// index options are not set - for new indices, we
148-
// need to set pruning to true by default
149-
// with a default pruning configuration
150-
return new IndexOptions(
151-
true,
152-
new PruningConfig(PruningConfig.DEFAULT_TOKENS_FREQ_RATIO_THRESHOLD, PruningConfig.DEFAULT_TOKENS_WEIGHT_THRESHOLD)
153-
);
147+
// index options are not set - for new indices,
148+
// if this is null, in the query will use the
149+
// proper defaults
150+
return null;
154151
}
155152

156153
private static SparseVectorFieldMapper.IndexOptions parseIndexOptions(MappingParserContext context, Object propNode) {

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/search/SparseVectorQueryBuilder.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,15 @@ private IndexFieldPruningSettings getIndexFieldPruningSettings(SparseVectorField
418418

419419
SparseVectorFieldMapper.IndexOptions indexOptions = sparseVectorFieldMapper.getIndexOptions();
420420
if (indexOptions == null) {
421-
return new IndexFieldPruningSettings(null, null);
421+
// return the default if not set in the index options
422+
return new IndexFieldPruningSettings(
423+
true,
424+
new TokenPruningConfig(
425+
TokenPruningConfig.DEFAULT_TOKENS_FREQ_RATIO_THRESHOLD,
426+
TokenPruningConfig.DEFAULT_TOKENS_WEIGHT_THRESHOLD,
427+
false
428+
)
429+
);
422430
}
423431

424432
Boolean indexOptionsPrune = indexOptions.getPrune();

0 commit comments

Comments
 (0)