Skip to content

Commit c46131d

Browse files
meili-bors[bot]meili-botbrunoocasali
authored
Merge #311
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 <[email protected]> Co-authored-by: Bruno Casali <[email protected]>
2 parents 5eec153 + 27bb0e9 commit c46131d

File tree

10 files changed

+166
-18
lines changed

10 files changed

+166
-18
lines changed

.code-samples.meilisearch.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,23 @@ search_parameter_guide_retrieve_1: |-
224224
search_parameter_guide_crop_1: |-
225225
client.index('movies').search('shifu', {
226226
attributes_to_crop: ['overview'],
227-
cropLength: 10
227+
crop_length: 5
228+
})
229+
search_parameter_guide_crop_marker_1: |-
230+
client.index('movies').search('shifu', {
231+
attributes_to_crop: ['overview'],
232+
crop_marker: "[…]"
228233
})
229234
search_parameter_guide_highlight_1: |-
230235
client.index('movies').search('winter feast', {
231236
attributes_to_highlight: ['overview']
232237
})
238+
search_parameter_guide_highlight_tag_1: |-
239+
client.index('movies').search('winter feast', {
240+
attributes_to_highlight: ['overview'],
241+
highlight_pre_tag: '<span class="highlight">',
242+
highlight_post_tag: '</span>'
243+
})
233244
search_parameter_guide_matches_1: |-
234245
client.index('movies').search('winter feast', {
235246
matches: true

.github/workflows/pre-release-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ jobs:
2727
- name: Get the latest MeiliSearch RC
2828
run: echo "MEILISEARCH_VERSION=$(curl https://raw.githubusercontent.com/meilisearch/integration-guides/main/scripts/get-latest-meilisearch-rc.sh | bash)" >> $GITHUB_ENV
2929
- name: MeiliSearch (${{ env.MEILISEARCH_VERSION }}) setup with Docker
30-
run: docker run -d -p 7700:7700 getmeili/meilisearch:${{ env.MEILISEARCH_VERSION }} ./meilisearch --master-key=masterKey --no-analytics
30+
run: docker run -d -p 7700:7700 getmeili/meilisearch:${{ env.MEILISEARCH_VERSION }} meilisearch --master-key=masterKey --no-analytics
3131
- name: Run test suite
3232
run: bundle exec rspec

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install ruby dependencies
3030
run: bundle install --with test
3131
- name: MeiliSearch (latest) setup with Docker
32-
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey --no-analytics
32+
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest meilisearch --master-key=masterKey --no-analytics
3333
- name: Run test suite
3434
run: bundle exec rspec
3535

.rubocop_todo.yml

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

99
# Offense count: 1
10-
# Cop supports --auto-correct.
10+
# This cop supports safe auto-correction (--auto-correct).
1111
# Configuration parameters: Include.
1212
# Include: **/*.gemspec
1313
Gemspec/RequireMFA:
1414
Exclude:
1515
- 'meilisearch.gemspec'
1616

1717
# Offense count: 1
18-
# Cop supports --auto-correct.
18+
# This cop supports safe auto-correction (--auto-correct).
1919
Layout/HeredocIndentation:
2020
Exclude:
2121
- 'spec/meilisearch/index/documents_spec.rb'
2222

23-
# Offense count: 33
23+
# Offense count: 43
2424
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
2525
# IgnoredMethods: refine
2626
Metrics/BlockLength:
27-
Max: 557
27+
Max: 558
2828

29-
# Offense count: 1
29+
# Offense count: 2
3030
# Configuration parameters: CountComments, CountAsOne.
3131
Metrics/ClassLength:
32-
Max: 278
32+
Max: 277
3333

3434
# Offense count: 1
3535
# Configuration parameters: Max, CountKeywordArgs.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ JSON output:
198198

199199
## 🤖 Compatibility with Meilisearch
200200

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

203203
## 💡 Learn More
204204

spec/meilisearch/index/search/attributes_to_crop_spec.rb

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,51 @@
1212

1313
before { index.add_documents!(document) }
1414

15+
it 'searches with default cropping params' do
16+
response = index.search('galaxy', attributesToCrop: ['*'], cropLength: 6)
17+
18+
expect(response.dig('hits', 0, '_formatted', 'description')).to eq('…Guide to the Galaxy is a…')
19+
end
20+
21+
it 'searches with custom crop markers' do
22+
response = index.search('galaxy', attributesToCrop: ['*'], cropLength: 6, cropMarker: '(ꈍᴗꈍ)')
23+
24+
expect(response.dig('hits', 0, '_formatted', 'description')).to eq('(ꈍᴗꈍ)Guide to the Galaxy is a(ꈍᴗꈍ)')
25+
end
26+
27+
it 'searches with mixed highlight and crop config' do
28+
response = index.search(
29+
'galaxy',
30+
attributesToHighlight: ['*'],
31+
attributesToCrop: ['*'],
32+
highlightPreTag: '<span class="bold">'
33+
)
34+
35+
expect(response.dig('hits', 0, '_formatted', 'description')).to \
36+
eq("…Hitchhiker's Guide to the <span class=\"bold\">Galaxy</em> is a comedy science…")
37+
end
38+
39+
it 'searches with highlight tags' do
40+
response = index.search(
41+
'galaxy',
42+
attributesToHighlight: ['*'],
43+
highlightPreTag: '<span>',
44+
highlightPostTag: '</span>'
45+
)
46+
47+
expect(response.dig('hits', 0, '_formatted', 'description')).to include('<span>Galaxy</span>')
48+
end
49+
1550
it 'does a custom search with attributes to crop' do
16-
response = index.search('galaxy', { attributesToCrop: ['description'], cropLength: 15 })
51+
response = index.search('galaxy', { attributesToCrop: ['description'], cropLength: 6 })
1752
expect(response['hits'].first).to have_key('_formatted')
18-
expect(response['hits'].first['_formatted']['description']).to eq('s Guide to the Galaxy is a comedy science')
53+
expect(response['hits'].first['_formatted']['description']).to eq('Guide to the Galaxy is a')
1954
end
2055

2156
it 'does a placehodler search with attributes to crop' do
22-
response = index.search('', { attributesToCrop: ['description'], cropLength: 20 })
57+
response = index.search('', { attributesToCrop: ['description'], cropLength: 5 })
2358
expect(response['hits'].first).to have_key('_formatted')
2459
expect(response['hits'].first['description']).to eq(document[:description])
25-
expect(response['hits'].first['_formatted']['description']).to eq("The Hitchhiker\'s Guide")
60+
expect(response['hits'].first['_formatted']['description']).to eq("The Hitchhiker\'s Guide to…")
2661
end
2762
end

spec/meilisearch/index/search/multi_params_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
})
1919
expect(response['hits'].count).to be(1)
2020
expect(response['hits'].first).to have_key('_formatted')
21-
expect(response['hits'].first['_formatted']['title']).to eq('Petit <em>Prince</em>')
21+
expect(response['hits'].first['_formatted']['title']).to eq('Petit <em>Prince</em>')
2222
end
2323

2424
it 'does a custom search with attributesToRetrieve and a limit' do
@@ -94,7 +94,7 @@
9494

9595
expect(response['hits'].count).to be(1)
9696
expect(response['hits'].first).to have_key('_formatted')
97-
expect(response['hits'].first['_formatted']['title']).to eq('Petit <em>Prince</em>')
97+
expect(response['hits'].first['_formatted']['title']).to eq('Petit <em>Prince</em>')
9898
end
9999
end
100100
end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe 'MeiliSearch::Index - nested fields search' do
4+
include_context 'search books with nested fields'
5+
6+
it 'searches without params' do
7+
response = index.search('an awesome')
8+
9+
expect(response['hits'].count).to eq(1)
10+
expect(response.dig('hits', 0, 'info', 'comment')).to eq('An awesome book')
11+
expect(response.dig('hits', 0, 'info', 'reviewNb')).to eq(900)
12+
end
13+
14+
it 'searches within index with searchableAttributes setting' do
15+
wait_for_it index.update_searchable_attributes(['title', 'info.comment'])
16+
wait_for_it index.add_documents(documents)
17+
18+
response = index.search('An awesome')
19+
20+
expect(response['hits'].count).to eq(1)
21+
expect(response.dig('hits', 0, 'info', 'comment')).to eq('An awesome book')
22+
expect(response.dig('hits', 0, 'info', 'reviewNb')).to eq(900)
23+
end
24+
25+
it 'searches within index with searchableAttributes and sortableAttributes settings' do
26+
wait_for_it index.update_searchable_attributes(['title', 'info.comment'])
27+
wait_for_it index.update_sortable_attributes(['info.reviewNb'])
28+
wait_for_it index.add_documents(documents)
29+
30+
response = index.search('An awesome')
31+
32+
expect(response['hits'].count).to eq(1)
33+
expect(response.dig('hits', 0, 'info', 'comment')).to eq('An awesome book')
34+
expect(response.dig('hits', 0, 'info', 'reviewNb')).to eq(900)
35+
end
36+
end

spec/meilisearch/index/settings_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
'stopWords',
2323
'synonyms',
2424
'filterableAttributes',
25-
'sortableAttributes'
25+
'sortableAttributes',
26+
'typoTolerance'
2627
]
2728
end
2829
let(:uid) { random_uid }

spec/support/books_contexts.rb

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,68 @@
9494
index.wait_for_task(response['uid'])
9595
end
9696
end
97+
98+
RSpec.shared_context 'search books with nested fields' do
99+
let(:index) { client.index('books') }
100+
let(:documents) do
101+
[
102+
{
103+
id: 1,
104+
title: 'Pride and Prejudice',
105+
info: {
106+
comment: 'A great book',
107+
reviewNb: 50
108+
}
109+
},
110+
{
111+
id: 2,
112+
title: 'Le Petit Prince',
113+
info: {
114+
comment: 'A french book',
115+
reviewNb: 600
116+
}
117+
},
118+
{
119+
id: 3,
120+
title: 'Le Rouge et le Noir',
121+
info: {
122+
comment: 'Another french book',
123+
reviewNb: 700
124+
}
125+
},
126+
{
127+
id: 4,
128+
title: 'Alice In Wonderland',
129+
info: {
130+
comment: 'A weird book',
131+
reviewNb: 800
132+
}
133+
},
134+
{
135+
id: 5,
136+
title: 'The Hobbit',
137+
info: {
138+
comment: 'An awesome book',
139+
reviewNb: 900
140+
}
141+
},
142+
{
143+
id: 6,
144+
title: 'Harry Potter and the Half-Blood Prince',
145+
info: {
146+
comment: 'The best book',
147+
reviewNb: 1000
148+
}
149+
},
150+
{
151+
id: 7,
152+
title: 'The Hitchhiker\'s Guide to the Galaxy'
153+
}
154+
]
155+
end
156+
157+
before do
158+
response = index.add_documents(documents)
159+
index.wait_for_task(response['uid'])
160+
end
161+
end

0 commit comments

Comments
 (0)