Skip to content
Merged
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 @@ -561,22 +561,26 @@ public void testQuantizationWithOverQueryParameter() throws Exception {
final RestClient restClient = getRestClient();
createKnnIndexMappingWithJVectorEngine(dimension, spaceType, VectorDataType.FLOAT);

// Choosing a batch size that will trigger quantization
// Disable refresh for the index
client().admin()
.indices()
.prepareUpdateSettings(INDEX_NAME)
.setSettings(Settings.builder().put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), -1))
.get();

// Choosing a batch size that should definitely trigger quantization
int batchSize = DEFAULT_MINIMUM_BATCH_SIZE_FOR_QUANTIZATION * 2;

final float[][] vectors = TestUtils.generateRandomVectors(batchSize, dimension);
final int totalDocs = vectors.length;

logger.info("Adding batch of vectors with size {} that is expected to trigger quantization", totalDocs);
CommonTestUtils.bulkAddKnnDocs(restClient, INDEX_NAME, FIELD_NAME, vectors, batchSize, false, 1000);
CommonTestUtils.flushIndex(restClient, INDEX_NAME);

// Force merge to trigger quantization for all segments
logger.info("Force merging just in case quantization didn't happen because of segment fragmentation");
CommonTestUtils.forceMergeKnnIndex(restClient, INDEX_NAME);

// Verify the total document count
int expectedTotalDocs = vectors.length;
logger.info("Adding batch of vectors with size {} that is expected to trigger quantization", totalDocs);
CommonTestUtils.bulkAddKnnDocs(restClient, INDEX_NAME, FIELD_NAME, vectors, batchSize, false, batchSize);
flushAndRefresh(INDEX_NAME);

// Verify the total document count (we expect 1 segment)
assertEquals(expectedTotalDocs, CommonTestUtils.getDocCount(restClient, INDEX_NAME));

// Perform search and verify recall
Expand Down
Loading