Skip to content
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 ci/docker-compose-azure-cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:1.18.2
image: semitechnologies/weaviate:1.19.0
ports:
- 8081:8081
restart: on-failure:0
Expand Down
6 changes: 3 additions & 3 deletions ci/docker-compose-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: '3.4'
services:
weaviate-node-1:
image: semitechnologies/weaviate:preview-gql-handler-consistency-level-integration-4a12f55
image: semitechnologies/weaviate:1.19.0
restart: on-failure:0
ports:
- "8087:8080"
Expand All @@ -25,7 +25,7 @@ services:
- '8080'
- --scheme
- http
image: semitechnologies/weaviate:preview-gql-handler-consistency-level-integration-4a12f55
image: semitechnologies/weaviate:1.19.0
ports:
- 8088:8080
- 6061:6060
Expand All @@ -38,7 +38,7 @@ services:
PERSISTENCE_DATA_PATH: './weaviate-node-2'
DEFAULT_VECTORIZER_MODULE: text2vec-contextionary
ENABLE_MODULES: text2vec-contextionary
CLUSTER_HOSTNAME: 'node2'
CLUSTER_HOSTNAME: 'node2'
CLUSTER_GOSSIP_BIND_PORT: '7112'
CLUSTER_DATA_BIND_PORT: '7113'
CLUSTER_JOIN: 'weaviate-node-1:7110'
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-compose-okta-cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:1.18.2
image: semitechnologies/weaviate:1.19.0
ports:
- 8082:8082
restart: on-failure:0
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-compose-okta-users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:1.18.2
image: semitechnologies/weaviate:1.19.0
ports:
- 8083:8083
restart: on-failure:0
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-compose-openai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
- '8086'
- --scheme
- http
image: semitechnologies/weaviate:1.18.2
image: semitechnologies/weaviate:1.19.0
ports:
- 8086:8086
restart: on-failure:0
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-compose-wcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- --scheme
- http
- --write-timeout=600s
image: semitechnologies/weaviate:1.18.2
image: semitechnologies/weaviate:1.19.0
ports:
- 8085:8085
restart: on-failure:0
Expand Down
4 changes: 2 additions & 2 deletions ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
version: '3.4'
services:
weaviate:
image: semitechnologies/weaviate:1.18.2
image: semitechnologies/weaviate:1.19.0
restart: on-failure:0
ports:
- "8080:8080"
Expand All @@ -17,7 +17,7 @@ services:
CLUSTER_GOSSIP_BIND_PORT: "7100"
CLUSTER_DATA_BIND_PORT: "7101"
contextionary:
image: semitechnologies/contextionary:en0.16.0-v1.2.0
image: semitechnologies/contextionary:en0.16.0-v1.2.1
ports:
- "9999:9999"
environment:
Expand Down
16 changes: 8 additions & 8 deletions src/batch/journey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ describe('batch deleting', () => {
.withClassName(thingClassName)
.withWhere({
operator: 'Equal',
valueString: 'bar1',
valueText: 'bar1',
path: ['stringProp'],
})
.withDryRun(true)
Expand All @@ -373,7 +373,7 @@ describe('batch deleting', () => {
where: {
operands: null,
operator: 'Equal',
valueString: 'bar1',
valueText: 'bar1',
path: ['stringProp'],
},
});
Expand All @@ -397,7 +397,7 @@ describe('batch deleting', () => {
.withClassName(otherThingClassName)
.withWhere({
operator: 'Like',
valueString: 'foo3',
valueText: 'foo3',
path: ['stringProp'],
})
.withDryRun(true)
Expand All @@ -411,7 +411,7 @@ describe('batch deleting', () => {
where: {
operands: null,
operator: 'Like',
valueString: 'foo3',
valueText: 'foo3',
path: ['stringProp'],
},
});
Expand All @@ -430,7 +430,7 @@ describe('batch deleting', () => {
.withClassName(otherThingClassName)
.withWhere({
operator: 'Equal',
valueString: 'doesNotExist',
valueText: 'doesNotExist',
path: ['stringProp'],
})
.do()
Expand All @@ -442,7 +442,7 @@ describe('batch deleting', () => {
where: {
operands: null,
operator: 'Equal',
valueString: 'doesNotExist',
valueText: 'doesNotExist',
path: ['stringProp'],
},
});
Expand All @@ -462,7 +462,7 @@ describe('batch deleting', () => {
.withClassName(otherThingClassName)
.withWhere({
operator: 'LessThan',
valueString: inAMinute,
valueText: inAMinute,
path: ['_creationTimeUnix'],
})
.withOutput('verbose')
Expand All @@ -476,7 +476,7 @@ describe('batch deleting', () => {
where: {
operands: null,
operator: 'LessThan',
valueString: inAMinute,
valueText: inAMinute,
path: ['_creationTimeUnix'],
},
});
Expand Down
4 changes: 2 additions & 2 deletions src/cluster/journey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const {
SOUP_CLASS_NAME,
} = require('../utils/testData');

const EXPECTED_WEAVIATE_VERSION = '1.18.2';
const EXPECTED_WEAVIATE_GIT_HASH = '723b88a';
const EXPECTED_WEAVIATE_VERSION = '1.19.0';
const EXPECTED_WEAVIATE_GIT_HASH = '48456a1';

describe('cluster nodes endpoint', () => {
const client = weaviate.client({
Expand Down
2 changes: 1 addition & 1 deletion src/data/journey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('data', () => {
.do()
.catch((e: Error) => {
expect(e.message).toEqual(
`usage error (422): {"error":[{"message":"invalid object: invalid string property 'stringProp' on class 'DataJourneyTestThing': not a string, but json.Number"}]}`
`usage error (422): {"error":[{"message":"invalid object: invalid text property 'stringProp' on class 'DataJourneyTestThing': not a string, but json.Number"}]}`
);
});
});
Expand Down
58 changes: 47 additions & 11 deletions src/graphql/getter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ describe('where filters', () => {
query: jest.fn(),
};

const expectedQuery = `{Get{Person(where:{operator:Equal,valueText:"John Doe",path:["name"]}){name}}}`;
const where: WhereFilter = {
operator: 'Equal',
valueText: 'John Doe',
path: ['name'],
};

new Getter(mockClient).withClassName('Person').withFields('name').withWhere(where).do();

expect(mockClient.query).toHaveBeenCalledWith(expectedQuery);
});

test('a query with a deprecated valueString', () => {
const mockClient: any = {
query: jest.fn(),
};

const expectedQuery = `{Get{Person(where:{operator:Equal,valueString:"John Doe",path:["name"]}){name}}}`;
const where: WhereFilter = {
operator: 'Equal',
Expand Down Expand Up @@ -1243,9 +1260,9 @@ describe('generative search', () => {
new Getter(mockClient)
.withClassName('Mammal')
.withGenerate({
singlePrompt: `Which mammals
can survive
in Antarctica?`,
singlePrompt: `Which mammals
can survive
in Antarctica?`,
})
.withFields('name taxonomy')
.do();
Expand Down Expand Up @@ -1278,14 +1295,14 @@ in Antarctica?`,
.withClassName('Mammal')
.withFields('name taxonomy')
.withGenerate({
groupedTask: `Tell
me
about
how
polar
bears
keep
warm`,
groupedTask: `Tell
me
about
how
polar
bears
keep
warm`,
})
.do();

Expand All @@ -1311,3 +1328,22 @@ warm`,
expect(mockClient.query).toHaveBeenCalledWith(expectedQuery);
});
});

describe('groupBy valid searchers', () => {
const mockClient: any = {
query: jest.fn(),
};

test('valid groupBy', () => {
const groupByQuery = `(groupBy:{path:["property"],groups:2,objectsPerGroup:3})`;
const expectedQuery = `{Get{Person` + groupByQuery + `{name}}}`;

new Getter(mockClient)
.withClassName('Person')
.withFields('name')
.withGroupBy({ path: ['property'], groups: 2, objectsPerGroup: 3 })
.do();

expect(mockClient.query).toHaveBeenCalledWith(expectedQuery);
});
});
15 changes: 15 additions & 0 deletions src/graphql/getter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { CommandBase } from '../validation/commandBase';
import { WhereFilter } from '../openapi/types';
import { GenerateArgs, GraphQLGenerate } from './generate';
import { ConsistencyLevel } from '../data';
import GroupBy, { GroupByArgs } from './groupBy';

export default class GraphQLGetter extends CommandBase {
private after?: string;
Expand All @@ -33,6 +34,7 @@ export default class GraphQLGetter extends CommandBase {
private whereString?: string;
private generateString?: string;
private consistencyLevel?: ConsistencyLevel;
private groupByString?: string;

constructor(client: Connection) {
super(client);
Expand Down Expand Up @@ -183,6 +185,15 @@ export default class GraphQLGetter extends CommandBase {
return this;
};

withGroupBy = (args: GroupByArgs) => {
try {
this.groupByString = new GroupBy(args).toString();
} catch (e: any) {
this.addError(e.toString());
}
return this;
};

validateIsSet = (prop: string | undefined | null, name: string, setter: string) => {
if (prop == undefined || prop == null || prop.length == 0) {
this.addError(`${name} must be set - set with ${setter}`);
Expand Down Expand Up @@ -267,6 +278,10 @@ export default class GraphQLGetter extends CommandBase {
args = [...args, `consistencyLevel:${this.consistencyLevel}`];
}

if (this.groupByString) {
args = [...args, `groupBy:${this.groupByString}`];
}

if (args.length > 0) {
params = `(${args.join(',')})`;
}
Expand Down
31 changes: 31 additions & 0 deletions src/graphql/groupBy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export interface GroupByArgs {
path: string[];
groups: number;
objectsPerGroup: number;
}

export default class GraphQLGroupBy {
private args: GroupByArgs;

constructor(args: GroupByArgs) {
this.args = args;
}

toString() {
let parts: string[] = [];

if (this.args.path) {
parts = [...parts, `path:${JSON.stringify(this.args.path)}`];
}

if (this.args.groups) {
parts = [...parts, `groups:${this.args.groups}`];
}

if (this.args.objectsPerGroup) {
parts = [...parts, `objectsPerGroup:${this.args.objectsPerGroup}`];
}

return `{${parts.join(',')}}`;
}
}
Loading