Skip to content

Add client-side logic allowing to update property descriptions #305

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

Merged
merged 2 commits into from
Jun 13, 2025
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
8 changes: 4 additions & 4 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ env:
WEAVIATE_124: 1.24.26
WEAVIATE_125: 1.25.34
WEAVIATE_126: 1.26.17
WEAVIATE_127: 1.27.15
WEAVIATE_128: 1.28.11
WEAVIATE_129: 1.29.1
WEAVIATE_130: 1.30.1
WEAVIATE_127: 1.27.27
WEAVIATE_128: 1.28.16
WEAVIATE_129: 1.29.8
WEAVIATE_130: 1.30.7
WEAVIATE_131: 1.31.0

concurrency:
Expand Down
17 changes: 16 additions & 1 deletion src/collections/config/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
GenerativeConfig,
GenerativeSearch,
ModuleConfig,
PropertyDescriptionsUpdate,
Reranker,
RerankerConfig,
VectorIndexType,
Expand All @@ -32,10 +33,12 @@ export class MergeWithExisting {
static schema(
current: WeaviateClass,
supportsNamedVectors: boolean,
update?: CollectionConfigUpdate
update?: CollectionConfigUpdate<any>
): WeaviateClass {
if (update === undefined) return current;
if (update.description !== undefined) current.description = update.description;
if (update.propertyDescriptions !== undefined)
current.properties = MergeWithExisting.properties(current.properties, update.propertyDescriptions);
if (update.generative !== undefined)
current.moduleConfig = MergeWithExisting.generative(current.moduleConfig, update.generative);
if (update.invertedIndex !== undefined)
Expand Down Expand Up @@ -74,6 +77,18 @@ export class MergeWithExisting {
return current;
}

static properties(
current: WeaviateClass['properties'],
update: PropertyDescriptionsUpdate<any>
): WeaviateClass['properties'] {
if (current === undefined) throw Error('Properties are missing from the class schema.');
if (current.length === 0) return current;
return current.map((property) => ({
...property,
description: update[property.name!] ?? property.description,
}));
}

static generative(
current: WeaviateModuleConfig,
update: ModuleConfig<GenerativeSearch, GenerativeConfig>
Expand Down
6 changes: 3 additions & 3 deletions src/collections/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const config = <T>(
)
).then(() => this.getShards());
},
update: (config?: CollectionConfigUpdate) => {
update: (config?: CollectionConfigUpdate<T>) => {
return getRaw()
.then(async (current) =>
MergeWithExisting.schema(
Expand Down Expand Up @@ -164,10 +164,10 @@ export interface Config<T> {
*
* Use the `weaviate.classes.Reconfigure` class to generate the necessary configuration objects for this method.
*
* @param {CollectionConfigUpdate} [config] The configuration to update. Only a subset of the actual collection configuration can be updated.
* @param {CollectionConfigUpdate<T>} [config] The configuration to update. Only a subset of the actual collection configuration can be updated.
* @returns {Promise<void>} A promise that resolves when the collection has been updated.
*/
update: (config?: CollectionConfigUpdate) => Promise<void>;
update: (config?: CollectionConfigUpdate<T>) => Promise<void>;
}

export class VectorIndex {
Expand Down
26 changes: 25 additions & 1 deletion src/collections/config/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ describe('Testing of the collection.config namespace', () => {
expect(notUpdated?.status).toEqual('READY');
});

it('should be able update the config of a collection', async () => {
it.only('should be able update the config of a collection', async () => {
const collectionName = 'TestCollectionConfigUpdate';
const collection = await client.collections.create({
name: collectionName,
Expand All @@ -520,11 +520,23 @@ describe('Testing of the collection.config namespace', () => {
name: 'testProp',
dataType: 'text',
},
{
name: 'testProp2',
dataType: 'text',
},
],
vectorizers: weaviate.configure.vectorizer.none(),
});
const supportsUpdatingPropertyDescriptions = await client
.getWeaviateVersion()
.then((ver) => ver.isAtLeast(1, 27, 0));
const config = await collection.config
.update({
propertyDescriptions: supportsUpdatingPropertyDescriptions
? {
testProp: 'This is a test property',
}
: undefined,
vectorizers: weaviate.reconfigure.vectorizer.update({
vectorIndexConfig: weaviate.reconfigure.vectorIndex.hnsw({
quantizer: weaviate.reconfigure.vectorIndex.quantizer.pq(),
Expand All @@ -539,6 +551,18 @@ describe('Testing of the collection.config namespace', () => {
{
name: 'testProp',
dataType: 'text',
description: supportsUpdatingPropertyDescriptions ? 'This is a test property' : undefined,
indexRangeFilters: false,
indexSearchable: true,
indexFilterable: true,
indexInverted: false,
vectorizerConfig: undefined,
nestedProperties: undefined,
tokenization: 'word',
},
{
name: 'testProp2',
dataType: 'text',
description: undefined,
indexRangeFilters: false,
indexSearchable: true,
Expand Down
9 changes: 8 additions & 1 deletion src/collections/config/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,15 @@ export type CollectionConfig = {
vectorizers: VectorConfig;
};

export type CollectionConfigUpdate = {
export type PropertyDescriptionsUpdate<T> = T extends undefined
? Record<string, string>
: {
[Property in keyof T]: string;
};

export type CollectionConfigUpdate<T> = {
description?: string;
propertyDescriptions?: PropertyDescriptionsUpdate<T>;
generative?: ModuleConfig<GenerativeSearch, GenerativeConfig>;
invertedIndex?: InvertedIndexConfigUpdate;
multiTenancy?: MultiTenancyConfigUpdate;
Expand Down