| 
1 | 1 | /* eslint-disable @typescript-eslint/no-non-null-assertion */  | 
2 | 2 | /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */  | 
 | 3 | +import { requireAtLeast } from '../../../test/version.js';  | 
3 | 4 | import weaviate, { WeaviateClient } from '../../index.js';  | 
4 | 5 | import { Collection } from '../collection/index.js';  | 
5 | 6 | import { CrossReference, Reference } from '../references/index.js';  | 
@@ -120,6 +121,34 @@ describe('Testing of the filter class with a simple collection', () => {  | 
120 | 121 |     expect(obj.uuid).toEqual(ids[1]);  | 
121 | 122 |   });  | 
122 | 123 | 
 
  | 
 | 124 | +  it('should filter a fetch objects query with a contains-all filter', async () => {  | 
 | 125 | +    const res = await collection.query.fetchObjects({  | 
 | 126 | +      filters: collection.filter.byProperty('text').containsAll(['two']),  | 
 | 127 | +    });  | 
 | 128 | +    expect(res.objects.length).toEqual(1);  | 
 | 129 | +    const obj = res.objects[0];  | 
 | 130 | +    expect(obj.properties.text).toEqual('two');  | 
 | 131 | +  });  | 
 | 132 | + | 
 | 133 | +  it('should filter a fetch objects query with a contains-any filter', async () => {  | 
 | 134 | +    const res = await collection.query.fetchObjects({  | 
 | 135 | +      filters: collection.filter.byProperty('text').containsAny(['two', 'three']),  | 
 | 136 | +    });  | 
 | 137 | +    expect(res.objects.length).toEqual(2);  | 
 | 138 | +    const texts = res.objects.map((o) => o.properties.text);  | 
 | 139 | +    expect(texts).toContain('two');  | 
 | 140 | +    expect(texts).toContain('three');  | 
 | 141 | +  });  | 
 | 142 | + | 
 | 143 | +  requireAtLeast(1, 33, 0).it('should filter a fetch objects query with a contains-none filter', async () => {  | 
 | 144 | +    const res = await collection.query.fetchObjects({  | 
 | 145 | +      filters: collection.filter.byProperty('text').containsNone(['one', 'three']),  | 
 | 146 | +    });  | 
 | 147 | +    expect(res.objects.length).toEqual(1);  | 
 | 148 | +    const obj = res.objects[0];  | 
 | 149 | +    expect(obj.properties.text).toEqual('two');  | 
 | 150 | +  });  | 
 | 151 | + | 
123 | 152 |   it('should filter a fetch objects query with an AND filter', async () => {  | 
124 | 153 |     const res = await collection.query.fetchObjects({  | 
125 | 154 |       filters: Filters.and(  | 
@@ -147,15 +176,16 @@ describe('Testing of the filter class with a simple collection', () => {  | 
147 | 176 |     // Return of fetch not necessarily in order due to filter  | 
148 | 177 |     expect(res.objects.map((o) => o.properties.text)).toContain('two');  | 
149 | 178 |     expect(res.objects.map((o) => o.properties.text)).toContain('three');  | 
 | 179 | +  });  | 
150 | 180 | 
 
  | 
151 |  | -    expect(res.objects.map((o) => o.properties.int)).toContain(2);  | 
152 |  | -    expect(res.objects.map((o) => o.properties.int)).toContain(3);  | 
153 |  | - | 
154 |  | -    expect(res.objects.map((o) => o.properties.float)).toContain(2.2);  | 
155 |  | -    expect(res.objects.map((o) => o.properties.float)).toContain(3.3);  | 
 | 181 | +  requireAtLeast(1, 33, 0).it('should filter a fetch objects query with a NOT filter', async () => {  | 
 | 182 | +    const res = await collection.query.fetchObjects({  | 
 | 183 | +      filters: Filters.not(collection.filter.byProperty('text').equal('one')),  | 
 | 184 | +    });  | 
 | 185 | +    expect(res.objects.length).toEqual(2);  | 
156 | 186 | 
 
  | 
157 |  | -    expect(res.objects.map((o) => o.uuid)).toContain(ids[1]);  | 
158 |  | -    expect(res.objects.map((o) => o.uuid)).toContain(ids[2]);  | 
 | 187 | +    expect(res.objects.map((o) => o.properties.text)).toContain('two');  | 
 | 188 | +    expect(res.objects.map((o) => o.properties.text)).toContain('three');  | 
159 | 189 |   });  | 
160 | 190 | 
 
  | 
161 | 191 |   it('should filter a fetch objects query with a reference filter', async () => {  | 
 | 
0 commit comments