Add vector index shard key

This commit is contained in:
Asier Isayas 2025-04-07 11:12:34 -04:00
parent 32576f50d3
commit f57691a229
2 changed files with 19 additions and 31 deletions

View File

@ -207,7 +207,7 @@ export interface IndexingPolicy {
export interface VectorIndex { export interface VectorIndex {
path: string; path: string;
type: "flat" | "diskANN" | "quantizedFlat"; type: "flat" | "diskANN" | "quantizedFlat";
diskANNShardKey?: string; vectorIndexShardKey?: string[];
indexingSearchListSize?: number; indexingSearchListSize?: number;
quantizationByteSize?: number; quantizationByteSize?: number;
} }

View File

@ -39,8 +39,7 @@ export interface VectorEmbeddingPolicyData {
indexType: VectorIndex["type"] | "none"; indexType: VectorIndex["type"] | "none";
pathError: string; pathError: string;
dimensionsError: string; dimensionsError: string;
diskANNShardKey?: string; vectorIndexShardKey?: string[];
diskANNShardKeyError?: string;
indexingSearchListSize?: number; indexingSearchListSize?: number;
indexingSearchListSizeError?: string; indexingSearchListSizeError?: string;
quantizationByteSize?: number; quantizationByteSize?: number;
@ -132,12 +131,6 @@ export const VectorEmbeddingPoliciesComponent: FunctionComponent<IVectorEmbeddin
return error; return error;
}; };
//TODO: no restrictions yet due to this field being removed for now.
// Uncomment and replace with validation code when field is reinstated
// const onDiskANNShardKeyError = (shardKey: string): string => {
// return "";
// };
const initializeData = (vectorEmbeddings: VectorEmbedding[], vectorIndexes: VectorIndex[]) => { const initializeData = (vectorEmbeddings: VectorEmbedding[], vectorIndexes: VectorIndex[]) => {
const mergedData: VectorEmbeddingPolicyData[] = []; const mergedData: VectorEmbeddingPolicyData[] = [];
vectorEmbeddings.forEach((embedding) => { vectorEmbeddings.forEach((embedding) => {
@ -147,6 +140,7 @@ export const VectorEmbeddingPoliciesComponent: FunctionComponent<IVectorEmbeddin
indexType: matchingIndex?.type || "none", indexType: matchingIndex?.type || "none",
indexingSearchListSize: matchingIndex?.indexingSearchListSize || undefined, indexingSearchListSize: matchingIndex?.indexingSearchListSize || undefined,
quantizationByteSize: matchingIndex?.quantizationByteSize || undefined, quantizationByteSize: matchingIndex?.quantizationByteSize || undefined,
vectorIndexShardKey: matchingIndex?.vectorIndexShardKey || undefined,
pathError: onVectorEmbeddingPathError(embedding.path), pathError: onVectorEmbeddingPathError(embedding.path),
dimensionsError: onVectorEmbeddingDimensionError(embedding.dimensions, matchingIndex?.type || "none"), dimensionsError: onVectorEmbeddingDimensionError(embedding.dimensions, matchingIndex?.type || "none"),
}); });
@ -186,6 +180,7 @@ export const VectorEmbeddingPoliciesComponent: FunctionComponent<IVectorEmbeddin
type: policy.indexType, type: policy.indexType,
indexingSearchListSize: policy.indexingSearchListSize, indexingSearchListSize: policy.indexingSearchListSize,
quantizationByteSize: policy.quantizationByteSize, quantizationByteSize: policy.quantizationByteSize,
vectorIndexShardKey: policy.vectorIndexShardKey
}) as VectorIndex, }) as VectorIndex,
); );
const validationPassed = vectorEmbeddingPolicyData.every( const validationPassed = vectorEmbeddingPolicyData.every(
@ -247,20 +242,16 @@ export const VectorEmbeddingPoliciesComponent: FunctionComponent<IVectorEmbeddin
setVectorEmbeddingPolicyData(vectorEmbeddings); setVectorEmbeddingPolicyData(vectorEmbeddings);
}; };
// TODO: uncomment after Ignite const onShardKeyChange = (index: number, event: React.ChangeEvent<HTMLInputElement>) => {
// DiskANNShardKey was removed for Ignite due to backend problems. Leaving this here as it will be reinstated immediately after Ignite const value = event.target.value.trim();
// const onDiskANNShardKeyChange = (index: number, event: React.ChangeEvent<HTMLInputElement>) => { const vectorEmbeddings = [...vectorEmbeddingPolicyData];
// const value = event.target.value.trim(); if (!vectorEmbeddings[index]?.vectorIndexShardKey?.[0] && !value.startsWith("/")) {
// const vectorEmbeddings = [...vectorEmbeddingPolicyData]; vectorEmbeddings[index].vectorIndexShardKey = ["/" + value];
// if (!vectorEmbeddings[index]?.diskANNShardKey && !value.startsWith("/")) { } else {
// vectorEmbeddings[index].diskANNShardKey = "/" + value; vectorEmbeddings[index].vectorIndexShardKey = [value];
// } else { }
// vectorEmbeddings[index].diskANNShardKey = value; setVectorEmbeddingPolicyData(vectorEmbeddings);
// } }
// const error = onDiskANNShardKeyError(value);
// vectorEmbeddings[index].diskANNShardKeyError = error;
// setVectorEmbeddingPolicyData(vectorEmbeddings);
// }
const onVectorEmbeddingPolicyChange = ( const onVectorEmbeddingPolicyChange = (
index: number, index: number,
@ -431,26 +422,23 @@ export const VectorEmbeddingPoliciesComponent: FunctionComponent<IVectorEmbeddin
} }
/> />
</Stack> </Stack>
{/*TODO: uncomment after Ignite */}
{/* DiskANNShardKey was removed for Ignite due to backend problems. Leaving this here as it will be reinstated immediately after Ignite
<Stack <Stack
style={{ marginLeft: "10px" }} style={{ marginLeft: "10px" }}
> >
<Label <Label
disabled={disabled || vectorEmbeddingPolicy.indexType !== "diskANN"} disabled={disabled || vectorEmbeddingPolicy.indexType !== "diskANN"}
styles={labelStyles} styles={labelStyles}
>DiskANN shard key</Label> >Shard key</Label>
<TextField <TextField
disabled={disabled || vectorEmbeddingPolicy.indexType !== "diskANN"} disabled={disabled || vectorEmbeddingPolicy.indexType !== "diskANN"}
id={`vector-policy-diskANNShardKey-${index + 1}`} id={`vector-policy-vectorIndexShardKey-${index + 1}`}
styles={textFieldStyles} styles={textFieldStyles}
value={String(vectorEmbeddingPolicy.diskANNShardKey || "")} value={String(vectorEmbeddingPolicy.vectorIndexShardKey?.[0] ?? "")}
onChange={(event: React.ChangeEvent<HTMLInputElement>) => onChange={(event: React.ChangeEvent<HTMLInputElement>) =>
onDiskANNShardKeyChange(index, event) onShardKeyChange(index, event)
} }
/> />
</Stack> </Stack>
*/}
</Stack> </Stack>
)} )}
</Stack> </Stack>