Skip to content

Commit

Permalink
Merge #311
Browse files Browse the repository at this point in the history
311: Changes related to the next Meilisearch release (v0.27.0) r=curquiza a=meili-bot

Related to this issue: meilisearch/integration-guides#190

This PR:
- gathers the changes related to the next Meilisearch release (v0.27.0) so that this package is ready when the official release is out.
- should pass the tests against the [latest pre-release of Meilisearch](https://github.com/meilisearch/meilisearch/releases).
- might eventually contain test failures until the Meilisearch v0.27.0 is out.

⚠️ This PR should NOT be merged until the next release of Meilisearch (v0.27.0) is out.

_This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/master/guides/pre-release-week.md) purpose._


Co-authored-by: meili-bot <74670311+meili-bot@users.noreply.github.com>
Co-authored-by: Bruno Casali <brunoocasali@gmail.com>
  • Loading branch information
3 people authored May 9, 2022
2 parents 5eec153 + 27bb0e9 commit c46131d
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 18 deletions.
13 changes: 12 additions & 1 deletion .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,23 @@ search_parameter_guide_retrieve_1: |-
search_parameter_guide_crop_1: |-
client.index('movies').search('shifu', {
attributes_to_crop: ['overview'],
cropLength: 10
crop_length: 5
})
search_parameter_guide_crop_marker_1: |-
client.index('movies').search('shifu', {
attributes_to_crop: ['overview'],
crop_marker: "[…]"
})
search_parameter_guide_highlight_1: |-
client.index('movies').search('winter feast', {
attributes_to_highlight: ['overview']
})
search_parameter_guide_highlight_tag_1: |-
client.index('movies').search('winter feast', {
attributes_to_highlight: ['overview'],
highlight_pre_tag: '<span class="highlight">',
highlight_post_tag: '</span>'
})
search_parameter_guide_matches_1: |-
client.index('movies').search('winter feast', {
matches: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-release-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ jobs:
- name: Get the latest MeiliSearch RC
run: echo "MEILISEARCH_VERSION=$(curl https://raw.githubusercontent.com/meilisearch/integration-guides/main/scripts/get-latest-meilisearch-rc.sh | bash)" >> $GITHUB_ENV
- name: MeiliSearch (${{ env.MEILISEARCH_VERSION }}) setup with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:${{ env.MEILISEARCH_VERSION }} ./meilisearch --master-key=masterKey --no-analytics
run: docker run -d -p 7700:7700 getmeili/meilisearch:${{ env.MEILISEARCH_VERSION }} meilisearch --master-key=masterKey --no-analytics
- name: Run test suite
run: bundle exec rspec
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install ruby dependencies
run: bundle install --with test
- name: MeiliSearch (latest) setup with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey --no-analytics
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --master-key=masterKey --no-analytics
- name: Run test suite
run: bundle exec rspec

Expand Down
14 changes: 7 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2021-12-13 22:26:31 UTC using RuboCop version 1.23.0.
# on 2022-04-26 02:54:29 UTC using RuboCop version 1.26.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Cop supports --auto-correct.
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequireMFA:
Exclude:
- 'meilisearch.gemspec'

# Offense count: 1
# Cop supports --auto-correct.
# This cop supports safe auto-correction (--auto-correct).
Layout/HeredocIndentation:
Exclude:
- 'spec/meilisearch/index/documents_spec.rb'

# Offense count: 33
# Offense count: 43
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 557
Max: 558

# Offense count: 1
# Offense count: 2
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 278
Max: 277

# Offense count: 1
# Configuration parameters: Max, CountKeywordArgs.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ JSON output:

## 🤖 Compatibility with Meilisearch

This package only guarantees the compatibility with the [version v0.26.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.26.0).
This package only guarantees the compatibility with the [version v0.27.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.27.0).

## 💡 Learn More

Expand Down
43 changes: 39 additions & 4 deletions spec/meilisearch/index/search/attributes_to_crop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,51 @@

before { index.add_documents!(document) }

it 'searches with default cropping params' do
response = index.search('galaxy', attributesToCrop: ['*'], cropLength: 6)

expect(response.dig('hits', 0, '_formatted', 'description')).to eq('…Guide to the Galaxy is a…')
end

it 'searches with custom crop markers' do
response = index.search('galaxy', attributesToCrop: ['*'], cropLength: 6, cropMarker: '(ꈍᴗꈍ)')

expect(response.dig('hits', 0, '_formatted', 'description')).to eq('(ꈍᴗꈍ)Guide to the Galaxy is a(ꈍᴗꈍ)')
end

it 'searches with mixed highlight and crop config' do
response = index.search(
'galaxy',
attributesToHighlight: ['*'],
attributesToCrop: ['*'],
highlightPreTag: '<span class="bold">'
)

expect(response.dig('hits', 0, '_formatted', 'description')).to \
eq("…Hitchhiker's Guide to the <span class=\"bold\">Galaxy</em> is a comedy science…")
end

it 'searches with highlight tags' do
response = index.search(
'galaxy',
attributesToHighlight: ['*'],
highlightPreTag: '<span>',
highlightPostTag: '</span>'
)

expect(response.dig('hits', 0, '_formatted', 'description')).to include('<span>Galaxy</span>')
end

it 'does a custom search with attributes to crop' do
response = index.search('galaxy', { attributesToCrop: ['description'], cropLength: 15 })
response = index.search('galaxy', { attributesToCrop: ['description'], cropLength: 6 })
expect(response['hits'].first).to have_key('_formatted')
expect(response['hits'].first['_formatted']['description']).to eq('s Guide to the Galaxy is a comedy science')
expect(response['hits'].first['_formatted']['description']).to eq('Guide to the Galaxy is a')
end

it 'does a placehodler search with attributes to crop' do
response = index.search('', { attributesToCrop: ['description'], cropLength: 20 })
response = index.search('', { attributesToCrop: ['description'], cropLength: 5 })
expect(response['hits'].first).to have_key('_formatted')
expect(response['hits'].first['description']).to eq(document[:description])
expect(response['hits'].first['_formatted']['description']).to eq("The Hitchhiker\'s Guide")
expect(response['hits'].first['_formatted']['description']).to eq("The Hitchhiker\'s Guide to…")
end
end
4 changes: 2 additions & 2 deletions spec/meilisearch/index/search/multi_params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
})
expect(response['hits'].count).to be(1)
expect(response['hits'].first).to have_key('_formatted')
expect(response['hits'].first['_formatted']['title']).to eq('Petit <em>Prince</em>')
expect(response['hits'].first['_formatted']['title']).to eq('Petit <em>Prince</em>')
end

it 'does a custom search with attributesToRetrieve and a limit' do
Expand Down Expand Up @@ -94,7 +94,7 @@

expect(response['hits'].count).to be(1)
expect(response['hits'].first).to have_key('_formatted')
expect(response['hits'].first['_formatted']['title']).to eq('Petit <em>Prince</em>')
expect(response['hits'].first['_formatted']['title']).to eq('Petit <em>Prince</em>')
end
end
end
36 changes: 36 additions & 0 deletions spec/meilisearch/index/search/nested_fields_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

RSpec.describe 'MeiliSearch::Index - nested fields search' do
include_context 'search books with nested fields'

it 'searches without params' do
response = index.search('an awesome')

expect(response['hits'].count).to eq(1)
expect(response.dig('hits', 0, 'info', 'comment')).to eq('An awesome book')
expect(response.dig('hits', 0, 'info', 'reviewNb')).to eq(900)
end

it 'searches within index with searchableAttributes setting' do
wait_for_it index.update_searchable_attributes(['title', 'info.comment'])
wait_for_it index.add_documents(documents)

response = index.search('An awesome')

expect(response['hits'].count).to eq(1)
expect(response.dig('hits', 0, 'info', 'comment')).to eq('An awesome book')
expect(response.dig('hits', 0, 'info', 'reviewNb')).to eq(900)
end

it 'searches within index with searchableAttributes and sortableAttributes settings' do
wait_for_it index.update_searchable_attributes(['title', 'info.comment'])
wait_for_it index.update_sortable_attributes(['info.reviewNb'])
wait_for_it index.add_documents(documents)

response = index.search('An awesome')

expect(response['hits'].count).to eq(1)
expect(response.dig('hits', 0, 'info', 'comment')).to eq('An awesome book')
expect(response.dig('hits', 0, 'info', 'reviewNb')).to eq(900)
end
end
3 changes: 2 additions & 1 deletion spec/meilisearch/index/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
'stopWords',
'synonyms',
'filterableAttributes',
'sortableAttributes'
'sortableAttributes',
'typoTolerance'
]
end
let(:uid) { random_uid }
Expand Down
65 changes: 65 additions & 0 deletions spec/support/books_contexts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,68 @@
index.wait_for_task(response['uid'])
end
end

RSpec.shared_context 'search books with nested fields' do
let(:index) { client.index('books') }
let(:documents) do
[
{
id: 1,
title: 'Pride and Prejudice',
info: {
comment: 'A great book',
reviewNb: 50
}
},
{
id: 2,
title: 'Le Petit Prince',
info: {
comment: 'A french book',
reviewNb: 600
}
},
{
id: 3,
title: 'Le Rouge et le Noir',
info: {
comment: 'Another french book',
reviewNb: 700
}
},
{
id: 4,
title: 'Alice In Wonderland',
info: {
comment: 'A weird book',
reviewNb: 800
}
},
{
id: 5,
title: 'The Hobbit',
info: {
comment: 'An awesome book',
reviewNb: 900
}
},
{
id: 6,
title: 'Harry Potter and the Half-Blood Prince',
info: {
comment: 'The best book',
reviewNb: 1000
}
},
{
id: 7,
title: 'The Hitchhiker\'s Guide to the Galaxy'
}
]
end

before do
response = index.add_documents(documents)
index.wait_for_task(response['uid'])
end
end

0 comments on commit c46131d

Please sign in to comment.