Fix for DenseVectorFieldMapperTests to properly initialize random vector given the dimensions in mappings (#129912)
This commit is contained in:
parent
56d5009924
commit
f095b3c592
|
@ -560,9 +560,6 @@ tests:
|
|||
- class: org.elasticsearch.xpack.rank.rrf.RRFRankClientYamlTestSuiteIT
|
||||
method: test {yaml=rrf/950_pinned_interaction/rrf with pinned retriever as a sub-retriever}
|
||||
issue: https://github.com/elastic/elasticsearch/issues/129845
|
||||
- class: org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapperTests
|
||||
method: testExistsQueryMinimalMapping
|
||||
issue: https://github.com/elastic/elasticsearch/issues/129911
|
||||
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
|
||||
method: test {p0=esql/60_usage/Basic ESQL usage output (telemetry) non-snapshot version}
|
||||
issue: https://github.com/elastic/elasticsearch/issues/129888
|
||||
|
@ -571,6 +568,7 @@ tests:
|
|||
extractedAssemble, #2]"
|
||||
issue: https://github.com/elastic/elasticsearch/issues/119871
|
||||
|
||||
|
||||
# Examples:
|
||||
#
|
||||
# Mute a single test case in a YAML test suite:
|
||||
|
|
|
@ -65,6 +65,7 @@ import java.util.Set;
|
|||
|
||||
import static org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat.DEFAULT_BEAM_WIDTH;
|
||||
import static org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat.DEFAULT_MAX_CONN;
|
||||
import static org.apache.lucene.tests.index.BaseKnnVectorsFormatTestCase.randomNormalizedVector;
|
||||
import static org.elasticsearch.index.codec.vectors.IVFVectorsFormat.DYNAMIC_NPROBE;
|
||||
import static org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.DEFAULT_OVERSAMPLE;
|
||||
import static org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.IVF_FORMAT;
|
||||
|
@ -147,7 +148,17 @@ public class DenseVectorFieldMapperTests extends MapperTestCase {
|
|||
|
||||
@Override
|
||||
protected Object getSampleValueForDocument() {
|
||||
return elementType == ElementType.FLOAT ? List.of(0.5, 0.5, 0.5, 0.5) : List.of((byte) 1, (byte) 1, (byte) 1, (byte) 1);
|
||||
return elementType == ElementType.FLOAT
|
||||
? convertToList(randomNormalizedVector(this.dims))
|
||||
: List.of((byte) 1, (byte) 1, (byte) 1, (byte) 1);
|
||||
}
|
||||
|
||||
private static List<Float> convertToList(float[] vector) {
|
||||
List<Float> list = new ArrayList<>(vector.length);
|
||||
for (float v : vector) {
|
||||
list.add(v);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue