|
5 | 5 | enable_vector_store(true) |
6 | 6 |
|
7 | 7 | documents = [ |
8 | | - { objectId: 0, _vectors: [0, 0.8, -0.2], title: 'Across The Universe' }, |
9 | | - { objectId: 1, _vectors: [1, -0.2, 0], title: 'All Things Must Pass' }, |
10 | | - { objectId: 2, _vectors: [0.5, 3, 1], title: 'And Your Bird Can Sing' } |
| 8 | + { objectId: 0, _vectors: { custom: [0, 0.8, -0.2] }, title: 'Across The Universe' }, |
| 9 | + { objectId: 1, _vectors: { custom: [1, -0.2, 0] }, title: 'All Things Must Pass' }, |
| 10 | + { objectId: 2, _vectors: { custom: [0.5, 3, 1] }, title: 'And Your Bird Can Sing' } |
11 | 11 | ] |
| 12 | + settings = { |
| 13 | + embedders: { |
| 14 | + custom: { |
| 15 | + source: 'userProvided', |
| 16 | + dimensions: 3 |
| 17 | + } |
| 18 | + } |
| 19 | + } |
12 | 20 |
|
13 | 21 | client.create_index('vector_test_search').await |
14 | 22 | new_index = client.index('vector_test_search') |
| 23 | + new_index.update_settings(settings).await |
15 | 24 | new_index.add_documents(documents).await |
16 | 25 |
|
17 | | - expect(new_index.search(vector: [9, 9, 9])['hits']).to be_empty |
| 26 | + expect(new_index.search('', |
| 27 | + { vector: [9, 9, 9], |
| 28 | + hybrid: { embedder: 'custom', semanticRatio: 1.0 } })['hits']).not_to be_empty |
| 29 | + expect(new_index.search('', |
| 30 | + { vector: [9, 9, 9], |
| 31 | + hybrid: { embedder: 'custom', semanticRatio: 1.0 } })['semanticHitCount']).to be 3 |
| 32 | + expect(new_index.search('All Things Must Pass', |
| 33 | + { vector: [9, 9, 9], |
| 34 | + hybrid: { embedder: 'custom', semanticRatio: 0.1 } })['semanticHitCount']).to be 2 |
18 | 35 | expect(new_index.search('All Things Must Pass')['hits']).not_to be_empty |
19 | 36 | end |
20 | 37 | end |
0 commit comments