Skip to content

Commit 09bd336

Browse files
committed
Fix meilisearch-ruby breakings after the update
1 parent 26f97d1 commit 09bd336

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lib/meilisearch-rails.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def self.log_or_throw(method, raise_on_failure, &block)
282282
case method.to_s
283283
when 'search'
284284
# some attributes are required
285-
{ 'hits' => [], 'hitsPerPage' => 0, 'page' => 0, 'facetsDistribution' => {}, 'error' => e }
285+
{ 'hits' => [], 'hitsPerPage' => 0, 'page' => 0, 'facetDistribution' => {}, 'error' => e }
286286
else
287287
# empty answer
288288
{ 'error' => e }
@@ -460,7 +460,7 @@ def ms_reindex!(batch_size = MeiliSearch::Rails::IndexSettings::DEFAULT_BATCH_SI
460460
end
461461
last_task = index.add_documents(documents)
462462
end
463-
index.wait_for_task(last_task['uid']) if last_task && (synchronous || options[:synchronous])
463+
index.wait_for_task(last_task['taskUid']) if last_task && (synchronous || options[:synchronous])
464464
end
465465
nil
466466
end
@@ -476,7 +476,7 @@ def ms_set_settings(synchronous = false)
476476

477477
index = SafeIndex.new(ms_index_uid(options), true, options)
478478
task = index.update_settings(final_settings)
479-
index.wait_for_task(task['uid']) if synchronous
479+
index.wait_for_task(task['taskUid']) if synchronous
480480
end
481481
end
482482

@@ -486,7 +486,7 @@ def ms_index_documents(documents, synchronous = false)
486486

487487
index = ms_ensure_init(options, settings)
488488
task = index.add_documents(documents.map { |d| settings.get_attributes(d).merge ms_pk(options) => ms_primary_key_of(d, options) })
489-
index.wait_for_task(task['uid']) if synchronous || options[:synchronous]
489+
index.wait_for_task(task['taskUid']) if synchronous || options[:synchronous]
490490
end
491491
end
492492

@@ -583,7 +583,7 @@ def ms_raw_answer
583583
end
584584

585585
def ms_facets_distribution
586-
@ms_json['facetsDistribution']
586+
@ms_json['facetDistribution']
587587
end
588588

589589
private
@@ -605,8 +605,8 @@ def ms_search(query, params = {})
605605
end
606606

607607
# Returns raw json hits as follows:
608-
# {"hits"=>[{"id"=>"13", "href"=>"apple", "name"=>"iphone"}], "offset"=>0, "limit"=>|| 20, "nbHits"=>1,
609-
# "exhaustiveNbHits"=>false, "processingTimeMs"=>0, "query"=>"iphone"}
608+
# {"hits"=>[{"id"=>"13", "href"=>"apple", "name"=>"iphone"}], "offset"=>0, "limit"=>|| 20, "estimatedTotalHits"=>1,
609+
# "processingTimeMs"=>0, "query"=>"iphone"}
610610
json = ms_raw_search(query, params)
611611

612612
# Returns the ids of the hits: 13

spec/integration_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ class SerializedDocument < ActiveRecord::Base
743743
end
744744

745745
it 'returns facets distribution' do
746-
results = Color.search('', { facetsDistribution: ['short_name'] })
746+
results = Color.search('', { facets: ['short_name'] })
747747
expect(results.raw_answer).not_to be_nil
748748
expect(results.facets_distribution).not_to be_nil
749749
expect(results.facets_distribution.size).to eq(1)
@@ -753,7 +753,7 @@ class SerializedDocument < ActiveRecord::Base
753753
it 'is raw searchable' do
754754
results = Color.raw_search('blue')
755755
expect(results['hits'].size).to eq(1)
756-
expect(results['nbHits']).to eq(1)
756+
expect(results['estimatedTotalHits']).to eq(1)
757757
end
758758

759759
it 'is able to temporarily disable auto-indexing' do

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def safe_index_uid(name)
5858

5959
# get a list of safe indexes in local or CI
6060
def safe_index_list
61-
list = MeiliSearch::Rails.client.indexes
61+
list = MeiliSearch::Rails.client.indexes['results']
6262
list = list.select { |index| index.uid.include?(SAFE_INDEX_PREFIX) }
6363
list.sort_by { |index| index.primary_key || '' }
6464
end

0 commit comments

Comments
 (0)