Skip to content

Commit 6c8de30

Browse files
committed
Add missing indexRangeFilters to API with tests of functionality
1 parent b2afb99 commit 6c8de30

File tree

6 files changed

+92
-27
lines changed

6 files changed

+92
-27
lines changed

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
env:
1010
WEAVIATE_124: 1.24.20
1111
WEAVIATE_125: 1.25.7
12-
WEAVIATE_126: preview--8758c8d
12+
WEAVIATE_126: preview--3aca6c5
1313

1414
jobs:
1515
checks:

src/collections/config/integration.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ describe('Testing of the collection.config namespace', () => {
4040
name: 'testProp',
4141
dataType: 'text',
4242
description: undefined,
43+
indexRangeFilters: false,
4344
indexSearchable: true,
4445
indexFilterable: true,
4546
indexInverted: false,
@@ -93,6 +94,7 @@ describe('Testing of the collection.config namespace', () => {
9394
name: 'testProp',
9495
dataType: 'text',
9596
description: undefined,
97+
indexRangeFilters: false,
9698
indexSearchable: true,
9799
indexFilterable: true,
98100
indexInverted: false,
@@ -342,6 +344,7 @@ describe('Testing of the collection.config namespace', () => {
342344
name: 'testProp',
343345
dataType: 'text',
344346
description: undefined,
347+
indexRangeFilters: false,
345348
indexSearchable: true,
346349
indexFilterable: true,
347350
indexInverted: false,
@@ -462,6 +465,7 @@ describe('Testing of the collection.config namespace', () => {
462465
name: 'testProp',
463466
dataType: 'text',
464467
description: undefined,
468+
indexRangeFilters: false,
465469
indexSearchable: true,
466470
indexFilterable: true,
467471
indexInverted: false,

src/collections/config/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export type PropertyConfig = {
5959
description?: string;
6060
indexInverted: boolean;
6161
indexFilterable: boolean;
62+
indexRangeFilters: boolean;
6263
indexSearchable: boolean;
6364
nestedProperties?: PropertyConfig[];
6465
tokenization: string;

src/collections/config/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ class ConfigMapping {
480480
description: prop.description,
481481
indexFilterable: prop.indexFilterable ? prop.indexFilterable : false,
482482
indexInverted: prop.indexInverted ? prop.indexInverted : false,
483+
indexRangeFilters: prop.indexRangeFilters ? prop.indexRangeFilters : false,
483484
indexSearchable: prop.indexSearchable ? prop.indexSearchable : false,
484485
vectorizerConfig: prop.moduleConfig
485486
? 'none' in prop.moduleConfig

src/collections/configure/types/base.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export type PropertyConfigCreateBase = {
6161
description?: string;
6262
indexInverted?: boolean;
6363
indexFilterable?: boolean;
64+
indexRangeFilters?: boolean;
6465
indexSearchable?: boolean;
6566
tokenization?: WeaviateProperty['tokenization'];
6667
skipVectorization?: boolean;
@@ -71,6 +72,7 @@ export type NestedPropertyConfigCreateBase = {
7172
description?: string;
7273
indexInverted?: boolean;
7374
indexFilterable?: boolean;
75+
indexRangeFilters?: boolean;
7476
indexSearchable?: boolean;
7577
tokenization?: WeaviateNestedProperty['tokenization'];
7678
};
@@ -83,6 +85,7 @@ export type PropertyConfigCreate<T> = T extends undefined
8385
nestedProperties?: NestedPropertyConfigCreate<T, DataType>[];
8486
indexInverted?: boolean;
8587
indexFilterable?: boolean;
88+
indexRangeFilters?: boolean;
8689
indexSearchable?: boolean;
8790
tokenization?: WeaviateProperty['tokenization'];
8891
skipVectorization?: boolean;

src/collections/integration.test.ts

Lines changed: 82 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@ import {
55
GeoCoordinate,
66
PQConfig,
77
PhoneNumber,
8+
PropertyConfig,
89
Text2VecContextionaryConfig,
910
Text2VecOpenAIConfig,
1011
VectorIndexConfigHNSW,
1112
} from './types/index';
1213

13-
const fail = (msg: string) => {
14-
throw new Error(msg);
15-
};
16-
1714
describe('Testing of the collections.create method', () => {
1815
let cluster: WeaviateClient;
1916
let contextionary: WeaviateClient;
@@ -34,6 +31,14 @@ describe('Testing of the collections.create method', () => {
3431
});
3532
});
3633

34+
afterAll(() =>
35+
Promise.all([
36+
cluster.collections.deleteAll(),
37+
contextionary.collections.deleteAll(),
38+
openai.collections.deleteAll(),
39+
])
40+
);
41+
3742
it('should be able to create a simple collection with a generic', async () => {
3843
const collectionName = 'TestCollectionSimpleGeneric';
3944
type TestCollectionSimple = {
@@ -57,8 +62,6 @@ describe('Testing of the collections.create method', () => {
5762
expect(response.vectorizers.default.indexConfig).toBeDefined();
5863
expect(response.vectorizers.default.indexType).toEqual('hnsw');
5964
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');
60-
61-
await contextionary.collections.delete(collectionName);
6265
});
6366

6467
it('should be able to create a simple collection without a generic', async () => {
@@ -81,8 +84,79 @@ describe('Testing of the collections.create method', () => {
8184
expect(response.vectorizers.default.indexConfig).toBeDefined();
8285
expect(response.vectorizers.default.indexType).toEqual('hnsw');
8386
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');
87+
});
8488

85-
await contextionary.collections.delete(collectionName);
89+
it('should be able to create a collection with one fully customised text property', () => {
90+
return contextionary.collections
91+
.create({
92+
name: 'TestCollectionTextProperty',
93+
properties: [
94+
{
95+
name: 'text',
96+
dataType: 'text',
97+
indexFilterable: true,
98+
indexSearchable: true,
99+
skipVectorization: true,
100+
tokenization: 'field',
101+
vectorizePropertyName: true,
102+
},
103+
],
104+
vectorizers: weaviate.configure.vectorizer.text2VecContextionary(),
105+
})
106+
.then((collection) => collection.config.get())
107+
.then((config) =>
108+
expect(config.properties[0]).toEqual<PropertyConfig>({
109+
name: 'text',
110+
dataType: 'text',
111+
indexFilterable: true,
112+
indexInverted: false,
113+
indexRangeFilters: false,
114+
indexSearchable: true,
115+
tokenization: 'field',
116+
vectorizerConfig: {
117+
'text2vec-contextionary': {
118+
skip: true,
119+
vectorizePropertyName: true,
120+
},
121+
},
122+
})
123+
);
124+
});
125+
126+
it('should be able to create a collection with one fully customised int property', () => {
127+
return contextionary.collections
128+
.create({
129+
name: 'TestCollectionIntProperty',
130+
properties: [
131+
{
132+
name: 'int',
133+
dataType: 'int',
134+
indexFilterable: true,
135+
indexRangeFilters: true,
136+
skipVectorization: true,
137+
vectorizePropertyName: true,
138+
},
139+
],
140+
vectorizers: weaviate.configure.vectorizer.text2VecContextionary(),
141+
})
142+
.then((collection) => collection.config.get())
143+
.then(async (config) =>
144+
expect(config.properties[0]).toEqual<PropertyConfig>({
145+
name: 'int',
146+
dataType: 'int',
147+
indexFilterable: true,
148+
indexInverted: false,
149+
indexRangeFilters: await contextionary.getWeaviateVersion().then((ver) => ver.isAtLeast(1, 26, 0)),
150+
indexSearchable: false,
151+
tokenization: 'none',
152+
vectorizerConfig: {
153+
'text2vec-contextionary': {
154+
skip: true,
155+
vectorizePropertyName: true,
156+
},
157+
},
158+
})
159+
);
86160
});
87161

88162
it('should be able to create a simple collection without a generic and no properties', async () => {
@@ -97,8 +171,6 @@ describe('Testing of the collections.create method', () => {
97171
expect(response.vectorizers.default.indexConfig).toBeDefined();
98172
expect(response.vectorizers.default.indexType).toEqual('hnsw');
99173
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');
100-
101-
await contextionary.collections.delete(collectionName);
102174
});
103175

104176
it('should be able to create a simple collection without a generic using a schema var', async () => {
@@ -123,8 +195,6 @@ describe('Testing of the collections.create method', () => {
123195
expect(response.vectorizers.default.indexConfig).toBeDefined();
124196
expect(response.vectorizers.default.indexType).toEqual('hnsw');
125197
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');
126-
127-
await contextionary.collections.delete(collectionName);
128198
});
129199

130200
it('should be able to create a simple collection with a generic using a schema var with const', async () => {
@@ -152,8 +222,6 @@ describe('Testing of the collections.create method', () => {
152222
expect(response.vectorizers.default.indexConfig).toBeDefined();
153223
expect(response.vectorizers.default.indexType).toEqual('hnsw');
154224
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');
155-
156-
await contextionary.collections.delete(collectionName);
157225
});
158226

159227
it('should be able to create a simple collection with a generic using a schema var with type', async () => {
@@ -181,8 +249,6 @@ describe('Testing of the collections.create method', () => {
181249
expect(response.vectorizers.default.indexConfig).toBeDefined();
182250
expect(response.vectorizers.default.indexType).toEqual('hnsw');
183251
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');
184-
185-
await contextionary.collections.delete(collectionName);
186252
});
187253

188254
it('should be able to create a nested collection', async () => {
@@ -219,8 +285,6 @@ describe('Testing of the collections.create method', () => {
219285
expect(response.vectorizers.default.indexConfig).toBeDefined();
220286
expect(response.vectorizers.default.indexType).toEqual('hnsw');
221287
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');
222-
223-
await contextionary.collections.delete(collectionName);
224288
});
225289

226290
it('should be able to create a collection with generic properties', () => {
@@ -248,7 +312,7 @@ describe('Testing of the collections.create method', () => {
248312
phoneNumber: PhoneNumber;
249313
};
250314

251-
cluster.collections.create<TestCollectionGenericProperties, 'TestCollectionGenericProperties'>({
315+
return cluster.collections.create<TestCollectionGenericProperties, 'TestCollectionGenericProperties'>({
252316
name: collectionName,
253317
properties: [
254318
{
@@ -539,8 +603,6 @@ describe('Testing of the collections.create method', () => {
539603
expect(response.vectorizers.default.indexType).toEqual('hnsw');
540604

541605
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');
542-
543-
await cluster.collections.delete(collectionName);
544606
});
545607

546608
it('should be able to create a collection with the contextionary vectorizer using configure.vectorizer', async () => {
@@ -569,8 +631,6 @@ describe('Testing of the collections.create method', () => {
569631
expect(
570632
(response.vectorizers.default.vectorizer.config as Text2VecContextionaryConfig).vectorizeCollectionName
571633
).toEqual(true);
572-
573-
await contextionary.collections.delete(collectionName);
574634
});
575635

576636
it('should be able to create a collection with an openai vectorizer with configure.vectorizer', async () => {
@@ -599,8 +659,6 @@ describe('Testing of the collections.create method', () => {
599659
expect(
600660
(response.vectorizers.default.vectorizer.config as Text2VecOpenAIConfig).vectorizeCollectionName
601661
).toEqual(true);
602-
603-
await openai.collections.delete(collectionName);
604662
});
605663

606664
it('should be able to create a collection with the openai generative with configure.Generative', async () => {
@@ -626,7 +684,5 @@ describe('Testing of the collections.create method', () => {
626684
name: 'generative-openai',
627685
config: {},
628686
});
629-
630-
await openai.collections.delete(collectionName);
631687
});
632688
});

0 commit comments

Comments
 (0)