Skip to content

Commit

Permalink
Make vector test compatible with Meilisearch v1.6+
Browse files Browse the repository at this point in the history
  • Loading branch information
dureuill committed Dec 3, 2024
1 parent 61aa49a commit 6dfc95f
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions spec/meilisearch/index/search/vector_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,33 @@
enable_vector_store(true)

documents = [
{ objectId: 0, _vectors: [0, 0.8, -0.2], title: 'Across The Universe' },
{ objectId: 1, _vectors: [1, -0.2, 0], title: 'All Things Must Pass' },
{ objectId: 2, _vectors: [0.5, 3, 1], title: 'And Your Bird Can Sing' }
{ objectId: 0, _vectors: { custom: [0, 0.8, -0.2] }, title: 'Across The Universe' },
{ objectId: 1, _vectors: { custom: [1, -0.2, 0] }, title: 'All Things Must Pass' },
{ objectId: 2, _vectors: { custom: [0.5, 3, 1] }, title: 'And Your Bird Can Sing' }
]
settings = {
embedders: {
custom: {
source: 'userProvided',
dimensions: 3
}
}
}

client.create_index('vector_test_search').await
new_index = client.index('vector_test_search')
new_index.update_settings(settings).await
new_index.add_documents(documents).await

expect(new_index.search(vector: [9, 9, 9])['hits']).to be_empty
expect(new_index.search('',
{ vector: [9, 9, 9],
hybrid: { embedder: 'custom', semanticRatio: 1.0 } })['hits']).not_to be_empty
expect(new_index.search('',
{ vector: [9, 9, 9],
hybrid: { embedder: 'custom', semanticRatio: 1.0 } })['semanticHitCount']).to be 3
expect(new_index.search('All Things Must Pass',
{ vector: [9, 9, 9],
hybrid: { embedder: 'custom', semanticRatio: 0.1 } })['semanticHitCount']).to be 2
expect(new_index.search('All Things Must Pass')['hits']).not_to be_empty
end
end

0 comments on commit 6dfc95f

Please sign in to comment.