Skip to content

Commit

Permalink
Merge pull request #85 from weaviate/contains-any-all-filters
Browse files Browse the repository at this point in the history
ContainsAny & ContainsAll Filter Operators
  • Loading branch information
antas-marcin authored Aug 18, 2023
2 parents 122db2a + d39611d commit 78cc66b
Show file tree
Hide file tree
Showing 12 changed files with 731 additions and 13 deletions.
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.21.0-rc.1
image: semitechnologies/weaviate:1.21.0
ports:
- 8081:8081
restart: on-failure:0
Expand Down
4 changes: 2 additions & 2 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:1.21.0-rc.1
image: semitechnologies/weaviate:1.21.0
restart: on-failure:0
ports:
- "8087:8080"
Expand All @@ -25,7 +25,7 @@ services:
- '8080'
- --scheme
- http
image: semitechnologies/weaviate:1.21.0-rc.1
image: semitechnologies/weaviate:1.21.0
ports:
- 8088:8080
- 6061:6060
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.21.0-rc.1
image: semitechnologies/weaviate:1.21.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.21.0-rc.1
image: semitechnologies/weaviate:1.21.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.21.0-rc.1
image: semitechnologies/weaviate:1.21.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.21.0-rc.1
image: semitechnologies/weaviate:1.21.0
ports:
- 8085:8085
restart: on-failure:0
Expand Down
2 changes: 1 addition & 1 deletion 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.21.0-rc.1
image: semitechnologies/weaviate:1.21.0
restart: on-failure:0
ports:
- "8080:8080"
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 @@ import {
SOUP_CLASS_NAME,
} from '../utils/testData';

const EXPECTED_WEAVIATE_VERSION = '1.21.0-rc.1';
const EXPECTED_WEAVIATE_GIT_HASH = 'b0d0063';
const EXPECTED_WEAVIATE_VERSION = '1.21.0';
const EXPECTED_WEAVIATE_GIT_HASH = '8172acb';

describe('cluster nodes endpoint', () => {
const client = weaviate.client({
Expand Down
111 changes: 111 additions & 0 deletions src/graphql/getter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1430,3 +1430,114 @@ describe('groupBy valid searchers', () => {
expect(mockClient.query).toHaveBeenCalledWith(expectedQuery);
});
});

describe('query with where with ContainsAny / ContainsAll operators', () => {
const mockClient: any = {
query: jest.fn(),
};

const operators: Array<WhereFilter['operator']> = ['ContainsAll', 'ContainsAny'];

test.each(operators)('valueTextArray with %s', (operator) => {
const whereQuery = `(where:{operator:` + operator + `,valueText:["red","blue","green"],path:["colors"]})`;
const expectedQuery = `{Get{WhereTest` + whereQuery + `{colors}}}`;

new Getter(mockClient)
.withClassName('WhereTest')
.withFields('colors')
.withWhere({
operator,
path: ['colors'],
valueTextArray: ['red', 'blue', 'green'],
})
.do();

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

test.each(operators)('valueStringArray with %s', (operator) => {
const whereQuery = `(where:{operator:` + operator + `,valueString:["red"],path:["colors"]})`;
const expectedQuery = `{Get{WhereTest` + whereQuery + `{colors}}}`;

new Getter(mockClient)
.withClassName('WhereTest')
.withFields('colors')
.withWhere({
operator,
path: ['colors'],
valueStringArray: ['red'],
})
.do();

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

test.each(operators)('valueNumberArray with %s', (operator) => {
const whereQuery = `(where:{operator:` + operator + `,valueNumber:[1.1,2.1],path:["numbers"]})`;
const expectedQuery = `{Get{WhereTest` + whereQuery + `{numbers}}}`;

new Getter(mockClient)
.withClassName('WhereTest')
.withFields('numbers')
.withWhere({
operator,
path: ['numbers'],
valueNumberArray: [1.1, 2.1],
})
.do();

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

test.each(operators)('valueIntArray with %s', (operator) => {
const whereQuery = `(where:{operator:` + operator + `,valueInt:[1],path:["numbers"]})`;
const expectedQuery = `{Get{WhereTest` + whereQuery + `{numbers}}}`;

new Getter(mockClient)
.withClassName('WhereTest')
.withFields('numbers')
.withWhere({
operator,
path: ['numbers'],
valueIntArray: [1],
})
.do();

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

test.each(operators)('valueDateArray with %s', (operator) => {
const whereQuery =
`(where:{operator:` + operator + `,valueDate:["2009-11-01T23:00:00Z"],path:["dates"]})`;
const expectedQuery = `{Get{WhereTest` + whereQuery + `{dates}}}`;

new Getter(mockClient)
.withClassName('WhereTest')
.withFields('dates')
.withWhere({
operator,
path: ['dates'],
valueDateArray: ['2009-11-01T23:00:00Z'],
})
.do();

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

test.each(operators)('valueBooleanArray with %s', (operator) => {
const whereQuery = `(where:{operator:` + operator + `,valueBoolean:[true,false],path:["bools"]})`;
const expectedQuery = `{Get{WhereTest` + whereQuery + `{bools}}}`;

new Getter(mockClient)
.withClassName('WhereTest')
.withFields('bools')
.withWhere({
operator,
path: ['bools'],
valueBooleanArray: [true, false],
})
.do();

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

0 comments on commit 78cc66b

Please sign in to comment.