-
Notifications
You must be signed in to change notification settings - Fork 4k
[fix](lance) Select metric-compatible vector index #67553
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
Changes from all commits
f290d9a
199361a
eb98910
5f2c2ba
eb80283
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -442,6 +442,134 @@ public void testExternalSearchFallsBackToFragmentSplitsForMetricMismatch() throw | |
| assertSplit(splits.get(1), 2, 8, 88); | ||
| } | ||
|
|
||
| @Test | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Add the required physical multi-index regression These cases construct |
||
| public void testExternalSearchSelectsLaterMetricCompatibleIndex() throws Exception { | ||
| UUID l2Segment = UUID.fromString("11111111-1111-1111-1111-111111111111"); | ||
| UUID cosineSegment = UUID.fromString("22222222-2222-2222-2222-222222222222"); | ||
| LanceTableMetadata metadata = LanceTableMetadata.withIndexSegments( | ||
| "s3://bucket/table.lance", | ||
| 42, | ||
| vectorSchema(), | ||
| Arrays.asList(new LanceFragmentInfo(1, 8, 8), new LanceFragmentInfo(2, 7, 7)), | ||
| Collections.singletonMap("vector", 9), | ||
| Arrays.asList( | ||
| new LanceIndexSegmentInfo(l2Segment, "a_l2", Collections.singletonList(9), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Supply the required index type in these fixtures
|
||
| Arrays.asList(1L, 2L), IndexType.VECTOR, "L2"), | ||
| new LanceIndexSegmentInfo(cosineSegment, "z_cosine", Collections.singletonList(9), | ||
| Arrays.asList(1L, 2L), IndexType.VECTOR, "COSINE")), | ||
| Collections.emptyMap()); | ||
| TExternalSearchRequest request = vectorSearchRequest(5, 0); | ||
| request.getSearchQuery().getVectorSearch().setMetric(TVectorMetric.COSINE); | ||
|
|
||
| List<Split> splits = newSearchNode(metadata, request).getSplits(2); | ||
|
|
||
| Assert.assertEquals(1, splits.size()); | ||
| assertIndexSplit(splits.get(0), cosineSegment, Arrays.asList(1L, 2L), 15, 100); | ||
| } | ||
|
|
||
| @Test | ||
| public void testExternalSearchSelectsMetricCompatibleIndexRegardlessOfMetadataOrder() throws Exception { | ||
| UUID cosineSegment = UUID.fromString("33333333-3333-3333-3333-333333333333"); | ||
| UUID l2Segment = UUID.fromString("44444444-4444-4444-4444-444444444444"); | ||
| LanceTableMetadata metadata = LanceTableMetadata.withIndexSegments( | ||
| "s3://bucket/table.lance", | ||
| 42, | ||
| vectorSchema(), | ||
| Arrays.asList(new LanceFragmentInfo(1, 8, 8), new LanceFragmentInfo(2, 7, 7)), | ||
| Collections.singletonMap("vector", 9), | ||
| Arrays.asList( | ||
| new LanceIndexSegmentInfo(cosineSegment, "z_cosine", Collections.singletonList(9), | ||
| Arrays.asList(1L, 2L), IndexType.VECTOR, "COSINE"), | ||
| new LanceIndexSegmentInfo(l2Segment, "a_l2", Collections.singletonList(9), | ||
| Arrays.asList(1L, 2L), IndexType.VECTOR, "L2")), | ||
| Collections.emptyMap()); | ||
| TExternalSearchRequest request = vectorSearchRequest(5, 0); | ||
| request.getSearchQuery().getVectorSearch().setMetric(TVectorMetric.COSINE); | ||
|
|
||
| List<Split> splits = newSearchNode(metadata, request).getSplits(2); | ||
|
|
||
| Assert.assertEquals(1, splits.size()); | ||
| assertIndexSplit(splits.get(0), cosineSegment, Arrays.asList(1L, 2L), 15, 100); | ||
| } | ||
|
|
||
| @Test | ||
| public void testExternalSearchSelectsSameMetricIndexByName() throws Exception { | ||
| UUID laterSegment = UUID.fromString("55555555-5555-5555-5555-555555555555"); | ||
| UUID firstSegment = UUID.fromString("66666666-6666-6666-6666-666666666666"); | ||
| UUID secondSegment = UUID.fromString("77777777-7777-7777-7777-777777777777"); | ||
| LanceTableMetadata metadata = LanceTableMetadata.withIndexSegments( | ||
| "s3://bucket/table.lance", | ||
| 42, | ||
| vectorSchema(), | ||
| Arrays.asList( | ||
| new LanceFragmentInfo(1, 8, 8), | ||
| new LanceFragmentInfo(2, 7, 7), | ||
| new LanceFragmentInfo(3, 6, 6)), | ||
| Collections.singletonMap("vector", 9), | ||
| Arrays.asList( | ||
| new LanceIndexSegmentInfo(laterSegment, "z_l2", Collections.singletonList(9), | ||
| Arrays.asList(1L, 2L, 3L), IndexType.VECTOR, "L2"), | ||
| new LanceIndexSegmentInfo(firstSegment, "a_l2", Collections.singletonList(9), | ||
| Collections.singletonList(1L), IndexType.VECTOR, "L2"), | ||
| new LanceIndexSegmentInfo(secondSegment, "a_l2", Collections.singletonList(9), | ||
| Collections.singletonList(2L), IndexType.VECTOR, "L2")), | ||
| Collections.emptyMap()); | ||
|
|
||
| List<Split> splits = newSearchNode(metadata, vectorSearchRequest(5, 0)).getSplits(2); | ||
|
|
||
| Assert.assertEquals(3, splits.size()); | ||
| assertIndexSplit(splits.get(0), firstSegment, Collections.singletonList(1L), 8, 100); | ||
| assertIndexSplit(splits.get(1), secondSegment, Collections.singletonList(2L), 8, 88); | ||
| assertSplit(splits.get(2), 3, 8, 75); | ||
| } | ||
|
|
||
| @Test | ||
| public void testExternalSearchDefaultMetricSelectsL2Index() throws Exception { | ||
| UUID l2Segment = UUID.fromString("99999999-9999-9999-9999-999999999999"); | ||
| LanceTableMetadata metadata = LanceTableMetadata.withIndexSegments( | ||
| "s3://bucket/table.lance", | ||
| 42, | ||
| vectorSchema(), | ||
| Collections.singletonList(new LanceFragmentInfo(1, 8, 8)), | ||
| Collections.singletonMap("vector", 9), | ||
| Collections.singletonList( | ||
| new LanceIndexSegmentInfo(l2Segment, "l2", Collections.singletonList(9), | ||
| Collections.singletonList(1L), IndexType.VECTOR, "L2")), | ||
| Collections.emptyMap()); | ||
| TExternalSearchRequest request = vectorSearchRequest(5, 0); | ||
| request.getSearchQuery().getVectorSearch().setMetric(TVectorMetric.DEFAULT); | ||
|
|
||
| List<Split> splits = newSearchNode(metadata, request).getSplits(1); | ||
|
|
||
| Assert.assertEquals(1, splits.size()); | ||
| assertIndexSplit(splits.get(0), l2Segment, Collections.singletonList(1L), 8, 100); | ||
| } | ||
|
|
||
| @Test | ||
| public void testExternalSearchSkipsIndexGroupWithoutFragmentBitmap() throws Exception { | ||
| UUID incompleteSegment = UUID.fromString("77777777-7777-7777-7777-777777777777"); | ||
| UUID cosineSegment = UUID.fromString("88888888-8888-8888-8888-888888888888"); | ||
| LanceTableMetadata metadata = LanceTableMetadata.withIndexSegments( | ||
| "s3://bucket/table.lance", | ||
| 42, | ||
| vectorSchema(), | ||
| Arrays.asList(new LanceFragmentInfo(1, 8, 8), new LanceFragmentInfo(2, 7, 7)), | ||
| Collections.singletonMap("vector", 9), | ||
| Arrays.asList( | ||
| new LanceIndexSegmentInfo(incompleteSegment, "a_incomplete", | ||
| Collections.singletonList(9), null, IndexType.VECTOR, "COSINE"), | ||
| new LanceIndexSegmentInfo(cosineSegment, "z_cosine", Collections.singletonList(9), | ||
| Arrays.asList(1L, 2L), IndexType.VECTOR, "COSINE")), | ||
| Collections.emptyMap()); | ||
| TExternalSearchRequest request = vectorSearchRequest(5, 0); | ||
| request.getSearchQuery().getVectorSearch().setMetric(TVectorMetric.COSINE); | ||
|
|
||
| List<Split> splits = newSearchNode(metadata, request).getSplits(2); | ||
|
|
||
| Assert.assertEquals(1, splits.size()); | ||
| assertIndexSplit(splits.get(0), cosineSegment, Arrays.asList(1L, 2L), 15, 100); | ||
| } | ||
|
|
||
| @Test | ||
| public void testExternalSearchRejectsMissingFieldIdForIndexSegmentPlanning() { | ||
| LanceTableMetadata metadata = LanceTableMetadata.withIndexSegments( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Update the documented selection contract
This now selects the lexicographically first safely plannable metric match, but the current English and Chinese 4.x Lance catalog docs still say Doris considers only one vector index per column and recommend creating at most one. Issue #67117 also makes removing that guidance and documenting a deterministic policy an acceptance criterion, while the in-repo matrix fixture comments still describe the old first-index limitation. Please update those docs/comments (or link the companion documentation change) so users are not told the opposite of the new behavior.