Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating testing and logging for dense_vector dynamic dims (#100546) #100833

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@ setup:
version: ' - 8.10.99'
reason: 'Dynamic mapping of floats to dense_vector was added in 8.11'

# Additional logging for issue: https://github.com/elastic/elasticsearch/issues/100502
- do:
cluster.put_settings:
body: >
{
"persistent": {
"logger.org.elasticsearch.index": "TRACE"
}
}

---
teardown:
- skip:
version: ' - 8.10.99'
reason: 'Dynamic mapping of floats to dense_vector was added in 8.11'

- do:
cluster.put_settings:
body: >
{
"persistent": {
"logger.org.elasticsearch.index": null
}
}
---
"Fields with float arrays below the threshold still map as float":

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import org.apache.lucene.search.FieldExistsQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.codec.CodecService;
import org.elasticsearch.index.codec.PerFieldMapperCodec;
Expand Down Expand Up @@ -231,6 +233,26 @@ public void testDims() {
}
}

public void testMergeDims() throws IOException {
XContentBuilder mapping = mapping(b -> {
b.startObject("field");
b.field("type", "dense_vector");
b.endObject();
});
MapperService mapperService = createMapperService(mapping);

mapping = mapping(b -> {
b.startObject("field");
b.field("type", "dense_vector").field("dims", 4).field("similarity", "cosine").field("index", true);
b.endObject();
});
merge(mapperService, mapping);
assertEquals(
XContentHelper.convertToMap(BytesReference.bytes(mapping), false, mapping.contentType()).v2(),
XContentHelper.convertToMap(mapperService.documentMapper().mappingSource().uncompressed(), false, mapping.contentType()).v2()
);
}

public void testDefaults() throws Exception {
DocumentMapper mapper = createDocumentMapper(fieldMapping(b -> b.field("type", "dense_vector").field("dims", 3)));

Expand Down