Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/125716.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 125716
summary: Return appropriate error on null dims update instead of npe
area: Vector Search
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -605,3 +605,28 @@ setup:
- match: { hits.hits.0._score: $knn_score0 }
- match: { hits.hits.1._score: $knn_score1 }
- match: { hits.hits.2._score: $knn_score2 }
---
"Updating dim to null is not allowed":
- requires:
cluster_features: "mapper.npe_on_dims_update_fix"
reason: "dims update fix"
- do:
indices.create:
index: test_index

- do:
indices.put_mapping:
index: test_index
body:
properties:
embedding:
type: dense_vector
dims: 4
- do:
catch: bad_request
indices.put_mapping:
index: test_index
body:
properties:
embedding:
type: dense_vector
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class MapperFeatures implements FeatureSpecification {
static final NodeFeature UKNOWN_FIELD_MAPPING_UPDATE_ERROR_MESSAGE = new NodeFeature(
"mapper.unknown_field_mapping_update_error_message"
);
static final NodeFeature NPE_ON_DIMS_UPDATE_FIX = new NodeFeature("mapper.npe_on_dims_update_fix");

@Override
public Set<NodeFeature> getTestFeatures() {
Expand All @@ -62,7 +63,8 @@ public Set<NodeFeature> getTestFeatures() {
UKNOWN_FIELD_MAPPING_UPDATE_ERROR_MESSAGE,
DOC_VALUES_SKIPPER,
RESCORE_VECTOR_QUANTIZED_VECTOR_MAPPING,
DateFieldMapper.INVALID_DATE_FIX
DateFieldMapper.INVALID_DATE_FIX,
NPE_ON_DIMS_UPDATE_FIX
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static class Builder extends FieldMapper.Builder {
}

return XContentMapValues.nodeIntegerValue(o);
}, m -> toType(m).fieldType().dims, XContentBuilder::field, Object::toString).setSerializerCheck((id, ic, v) -> v != null)
}, m -> toType(m).fieldType().dims, XContentBuilder::field, Objects::toString).setSerializerCheck((id, ic, v) -> v != null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is kinda gross to read; might help in the future to see that default value on a separate line which might have maybe might have made it more obvious that Objects::toString is needed here more similar to how this is formatted in DateScriptFieldType:65 which breaks this Parameter instantiation out into an arg per line.

.setMergeValidator((previous, current, c) -> previous == null || Objects.equals(previous, current))
.addValidator(dims -> {
if (dims == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static class Builder extends FieldMapper.Builder {
}

return XContentMapValues.nodeIntegerValue(o);
}, m -> toType(m).fieldType().dims, XContentBuilder::field, Object::toString).setSerializerCheck((id, ic, v) -> v != null)
}, m -> toType(m).fieldType().dims, XContentBuilder::field, Objects::toString).setSerializerCheck((id, ic, v) -> v != null)
.setMergeValidator((previous, current, c) -> previous == null || Objects.equals(previous, current))
.addValidator(dims -> {
if (dims == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,28 @@ setup:
id: "1"
body:
vector1: [[2, -1, 1], [[2, -1, 1]]]
---
"Updating dim to null is not allowed":
- requires:
cluster_features: "mapper.npe_on_dims_update_fix"
reason: "dims update fix"
- do:
indices.create:
index: test_index

- do:
indices.put_mapping:
index: test_index
body:
properties:
embedding:
type: rank_vectors
dims: 4
- do:
catch: bad_request
indices.put_mapping:
index: test_index
body:
properties:
embedding:
type: rank_vectors
Loading