Skip to content
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

Add missing indexRangeFilters to API with tests of functionality #171

Merged
merged 2 commits into from
Jul 18, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
env:
WEAVIATE_124: 1.24.20
WEAVIATE_125: 1.25.7
WEAVIATE_126: preview--8758c8d
WEAVIATE_126: preview--3aca6c5

jobs:
checks:
Expand Down
4 changes: 4 additions & 0 deletions src/collections/config/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('Testing of the collection.config namespace', () => {
name: 'testProp',
dataType: 'text',
description: undefined,
indexRangeFilters: false,
indexSearchable: true,
indexFilterable: true,
indexInverted: false,
Expand Down Expand Up @@ -93,6 +94,7 @@ describe('Testing of the collection.config namespace', () => {
name: 'testProp',
dataType: 'text',
description: undefined,
indexRangeFilters: false,
indexSearchable: true,
indexFilterable: true,
indexInverted: false,
Expand Down Expand Up @@ -342,6 +344,7 @@ describe('Testing of the collection.config namespace', () => {
name: 'testProp',
dataType: 'text',
description: undefined,
indexRangeFilters: false,
indexSearchable: true,
indexFilterable: true,
indexInverted: false,
Expand Down Expand Up @@ -462,6 +465,7 @@ describe('Testing of the collection.config namespace', () => {
name: 'testProp',
dataType: 'text',
description: undefined,
indexRangeFilters: false,
indexSearchable: true,
indexFilterable: true,
indexInverted: false,
Expand Down
1 change: 1 addition & 0 deletions src/collections/config/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export type PropertyConfig = {
description?: string;
indexInverted: boolean;
indexFilterable: boolean;
indexRangeFilters: boolean;
indexSearchable: boolean;
nestedProperties?: PropertyConfig[];
tokenization: string;
Expand Down
1 change: 1 addition & 0 deletions src/collections/config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ class ConfigMapping {
description: prop.description,
indexFilterable: prop.indexFilterable ? prop.indexFilterable : false,
indexInverted: prop.indexInverted ? prop.indexInverted : false,
indexRangeFilters: prop.indexRangeFilters ? prop.indexRangeFilters : false,
indexSearchable: prop.indexSearchable ? prop.indexSearchable : false,
vectorizerConfig: prop.moduleConfig
? 'none' in prop.moduleConfig
Expand Down
3 changes: 3 additions & 0 deletions src/collections/configure/types/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type PropertyConfigCreateBase = {
description?: string;
indexInverted?: boolean;
indexFilterable?: boolean;
indexRangeFilters?: boolean;
indexSearchable?: boolean;
tokenization?: WeaviateProperty['tokenization'];
skipVectorization?: boolean;
Expand All @@ -71,6 +72,7 @@ export type NestedPropertyConfigCreateBase = {
description?: string;
indexInverted?: boolean;
indexFilterable?: boolean;
indexRangeFilters?: boolean;
indexSearchable?: boolean;
tokenization?: WeaviateNestedProperty['tokenization'];
};
Expand All @@ -83,6 +85,7 @@ export type PropertyConfigCreate<T> = T extends undefined
nestedProperties?: NestedPropertyConfigCreate<T, DataType>[];
indexInverted?: boolean;
indexFilterable?: boolean;
indexRangeFilters?: boolean;
indexSearchable?: boolean;
tokenization?: WeaviateProperty['tokenization'];
skipVectorization?: boolean;
Expand Down
110 changes: 83 additions & 27 deletions src/collections/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import {
GeoCoordinate,
PQConfig,
PhoneNumber,
PropertyConfig,
Text2VecContextionaryConfig,
Text2VecOpenAIConfig,
VectorIndexConfigHNSW,
} from './types/index';

const fail = (msg: string) => {
throw new Error(msg);
};

describe('Testing of the collections.create method', () => {
let cluster: WeaviateClient;
let contextionary: WeaviateClient;
Expand All @@ -34,6 +31,14 @@ describe('Testing of the collections.create method', () => {
});
});

afterAll(() =>
Promise.all([
cluster.collections.deleteAll(),
contextionary.collections.deleteAll(),
openai.collections.deleteAll(),
])
);

it('should be able to create a simple collection with a generic', async () => {
const collectionName = 'TestCollectionSimpleGeneric';
type TestCollectionSimple = {
Expand All @@ -57,8 +62,6 @@ describe('Testing of the collections.create method', () => {
expect(response.vectorizers.default.indexConfig).toBeDefined();
expect(response.vectorizers.default.indexType).toEqual('hnsw');
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');

await contextionary.collections.delete(collectionName);
});

it('should be able to create a simple collection without a generic', async () => {
Expand All @@ -81,12 +84,83 @@ describe('Testing of the collections.create method', () => {
expect(response.vectorizers.default.indexConfig).toBeDefined();
expect(response.vectorizers.default.indexType).toEqual('hnsw');
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');
});

await contextionary.collections.delete(collectionName);
it('should be able to create a collection with one fully customised text property', () => {
return contextionary.collections
.create({
name: 'TestCollectionTextProperty',
properties: [
{
name: 'text',
dataType: 'text',
indexFilterable: true,
indexSearchable: true,
skipVectorization: true,
tokenization: 'field',
vectorizePropertyName: true,
},
],
vectorizers: weaviate.configure.vectorizer.text2VecContextionary(),
})
.then((collection) => collection.config.get())
.then((config) =>
expect(config.properties[0]).toEqual<PropertyConfig>({
name: 'text',
dataType: 'text',
indexFilterable: true,
indexInverted: false,
indexRangeFilters: false,
indexSearchable: true,
tokenization: 'field',
vectorizerConfig: {
'text2vec-contextionary': {
skip: true,
vectorizePropertyName: true,
},
},
})
);
});

it('should be able to create a collection with one fully customised int property', () => {
return contextionary.collections
.create({
name: 'TestCollectionIntProperty',
properties: [
{
name: 'int',
dataType: 'int',
indexFilterable: true,
indexRangeFilters: true,
skipVectorization: true,
vectorizePropertyName: true,
},
],
vectorizers: weaviate.configure.vectorizer.text2VecContextionary(),
})
.then((collection) => collection.config.get())
.then(async (config) =>
expect(config.properties[0]).toEqual<PropertyConfig>({
name: 'int',
dataType: 'int',
indexFilterable: true,
indexInverted: false,
indexRangeFilters: await contextionary.getWeaviateVersion().then((ver) => ver.isAtLeast(1, 26, 0)),
indexSearchable: false,
tokenization: 'none',
vectorizerConfig: {
'text2vec-contextionary': {
skip: true,
vectorizePropertyName: true,
},
},
})
);
});

it('should be able to create a simple collection without a generic and no properties', async () => {
const collectionName = 'TestCollectionSimpleNonGeneric';
const collectionName = 'TestCollectionSimpleNonGenericNoProperties';
const response = await contextionary.collections
.create({
name: collectionName,
Expand All @@ -97,8 +171,6 @@ describe('Testing of the collections.create method', () => {
expect(response.vectorizers.default.indexConfig).toBeDefined();
expect(response.vectorizers.default.indexType).toEqual('hnsw');
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');

await contextionary.collections.delete(collectionName);
});

it('should be able to create a simple collection without a generic using a schema var', async () => {
Expand All @@ -123,8 +195,6 @@ describe('Testing of the collections.create method', () => {
expect(response.vectorizers.default.indexConfig).toBeDefined();
expect(response.vectorizers.default.indexType).toEqual('hnsw');
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');

await contextionary.collections.delete(collectionName);
});

it('should be able to create a simple collection with a generic using a schema var with const', async () => {
Expand Down Expand Up @@ -152,8 +222,6 @@ describe('Testing of the collections.create method', () => {
expect(response.vectorizers.default.indexConfig).toBeDefined();
expect(response.vectorizers.default.indexType).toEqual('hnsw');
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');

await contextionary.collections.delete(collectionName);
});

it('should be able to create a simple collection with a generic using a schema var with type', async () => {
Expand Down Expand Up @@ -181,8 +249,6 @@ describe('Testing of the collections.create method', () => {
expect(response.vectorizers.default.indexConfig).toBeDefined();
expect(response.vectorizers.default.indexType).toEqual('hnsw');
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');

await contextionary.collections.delete(collectionName);
});

it('should be able to create a nested collection', async () => {
Expand Down Expand Up @@ -219,8 +285,6 @@ describe('Testing of the collections.create method', () => {
expect(response.vectorizers.default.indexConfig).toBeDefined();
expect(response.vectorizers.default.indexType).toEqual('hnsw');
expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');

await contextionary.collections.delete(collectionName);
});

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

cluster.collections.create<TestCollectionGenericProperties, 'TestCollectionGenericProperties'>({
return cluster.collections.create<TestCollectionGenericProperties, 'TestCollectionGenericProperties'>({
name: collectionName,
properties: [
{
Expand Down Expand Up @@ -539,8 +603,6 @@ describe('Testing of the collections.create method', () => {
expect(response.vectorizers.default.indexType).toEqual('hnsw');

expect(response.vectorizers.default.vectorizer.name).toEqual('text2vec-contextionary');

await cluster.collections.delete(collectionName);
});

it('should be able to create a collection with the contextionary vectorizer using configure.vectorizer', async () => {
Expand Down Expand Up @@ -569,8 +631,6 @@ describe('Testing of the collections.create method', () => {
expect(
(response.vectorizers.default.vectorizer.config as Text2VecContextionaryConfig).vectorizeCollectionName
).toEqual(true);

await contextionary.collections.delete(collectionName);
});

it('should be able to create a collection with an openai vectorizer with configure.vectorizer', async () => {
Expand Down Expand Up @@ -599,8 +659,6 @@ describe('Testing of the collections.create method', () => {
expect(
(response.vectorizers.default.vectorizer.config as Text2VecOpenAIConfig).vectorizeCollectionName
).toEqual(true);

await openai.collections.delete(collectionName);
});

it('should be able to create a collection with the openai generative with configure.Generative', async () => {
Expand All @@ -626,7 +684,5 @@ describe('Testing of the collections.create method', () => {
name: 'generative-openai',
config: {},
});

await openai.collections.delete(collectionName);
});
});
4 changes: 4 additions & 0 deletions src/collections/journey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ describe('Journey testing of the client using a WCD cluster', () => {
dataType: 'text',
indexFilterable: true,
indexInverted: false,
indexRangeFilters: false,
indexSearchable: true,
vectorizerConfig: {
'text2vec-cohere': {
Expand All @@ -100,6 +101,7 @@ describe('Journey testing of the client using a WCD cluster', () => {
dataType: 'int',
indexFilterable: true,
indexInverted: false,
indexRangeFilters: false,
indexSearchable: false,
vectorizerConfig: {
'text2vec-cohere': {
Expand All @@ -114,6 +116,7 @@ describe('Journey testing of the client using a WCD cluster', () => {
dataType: 'geoCoordinates',
indexFilterable: true,
indexInverted: false,
indexRangeFilters: false,
indexSearchable: false,
vectorizerConfig: {
'text2vec-cohere': {
Expand All @@ -128,6 +131,7 @@ describe('Journey testing of the client using a WCD cluster', () => {
dataType: 'date',
indexFilterable: true,
indexInverted: false,
indexRangeFilters: false,
indexSearchable: false,
vectorizerConfig: {
'text2vec-cohere': {
Expand Down
Loading