meilisearch-rails 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +3 -2
- data/README.md +2 -2
- data/lib/meilisearch/version.rb +1 -1
- data/lib/meilisearch-rails.rb +16 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e61a10b5b9eaf11606209ff295728cdd962acdb4f21d02004d416ed7346a3212
|
4
|
+
data.tar.gz: bd8b788affabaa81eafbcd027e223179c356e3d21af2083f335d2def1def71af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e3af82f062f7578f8008c15050c67c1241b9922613e65dfeb8fb9c7ef6816e2900eb76b0836e726e3af0c408401761f6e9582ccd3ebd10173db49fc978b7015
|
7
|
+
data.tar.gz: '02424401493f9e983fa5b0b556e388191ef9612c7ab799cc781ed05bf8a42cb8a54cf98d3062bcd0c7525e81e0a986326fd37b89c853d83981bbf1332e0c9329'
|
data/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
gem 'json', '~> 2.5', '>= 2.5.1'
|
4
|
-
gem 'meilisearch', '~> 0.
|
4
|
+
gem 'meilisearch', '~> 0.18.0'
|
5
5
|
|
6
6
|
gem 'rubysl', '~> 2.0', platform: :rbx if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
7
7
|
|
@@ -28,7 +28,8 @@ group :test do
|
|
28
28
|
gem 'activerecord-jdbc-adapter', platform: :jruby
|
29
29
|
gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
|
30
30
|
gem 'jdbc-sqlite3', platform: :jruby
|
31
|
-
gem 'rspec', '
|
31
|
+
gem 'rspec', '~> 3.0'
|
32
|
+
gem 'simplecov', require: 'false'
|
32
33
|
|
33
34
|
gem 'byebug'
|
34
35
|
gem 'dotenv', '~> 2.7', '>= 2.7.6'
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ To learn more about MeiliSearch, check out our [Documentation](https://docs.meil
|
|
58
58
|
|
59
59
|
## 🤖 Compatibility with MeiliSearch
|
60
60
|
|
61
|
-
This package only guarantees the compatibility with the [version v0.
|
61
|
+
This package only guarantees the compatibility with the [version v0.25.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.25.0).
|
62
62
|
|
63
63
|
## 🔧 Installation <!-- omit in toc -->
|
64
64
|
|
@@ -659,7 +659,7 @@ class Book < ActiveRecord::Base
|
|
659
659
|
end
|
660
660
|
end
|
661
661
|
```
|
662
|
-
🚨 This is only recommended for testing purposes, the gem will call the `
|
662
|
+
🚨 This is only recommended for testing purposes, the gem will call the `wait_for_task` method that will stop your code execution until the asynchronous task has been processed by MeilSearch.
|
663
663
|
|
664
664
|
##### Disable auto-indexing & auto-removal <!-- omit in toc -->
|
665
665
|
|
data/lib/meilisearch/version.rb
CHANGED
data/lib/meilisearch-rails.rb
CHANGED
@@ -129,7 +129,7 @@ module MeiliSearch
|
|
129
129
|
|
130
130
|
def attributes_to_hash(attributes, document)
|
131
131
|
if attributes
|
132
|
-
attributes.
|
132
|
+
attributes.to_h { |name, value| [name.to_s, value.call(document)] }
|
133
133
|
else
|
134
134
|
{}
|
135
135
|
end
|
@@ -237,7 +237,8 @@ module MeiliSearch
|
|
237
237
|
def initialize(index_uid, raise_on_failure, options)
|
238
238
|
client = MeiliSearch.client
|
239
239
|
primary_key = options[:primary_key] || MeiliSearch::IndexSettings::DEFAULT_PRIMARY_KEY
|
240
|
-
|
240
|
+
client.create_index(index_uid, { primaryKey: primary_key })
|
241
|
+
@index = client.index(index_uid)
|
241
242
|
@raise_on_failure = raise_on_failure.nil? || raise_on_failure
|
242
243
|
end
|
243
244
|
|
@@ -254,12 +255,12 @@ module MeiliSearch
|
|
254
255
|
end
|
255
256
|
end
|
256
257
|
|
257
|
-
# special handling of
|
258
|
-
def
|
259
|
-
return if
|
258
|
+
# special handling of wait_for_task to handle null task_id
|
259
|
+
def wait_for_task(task_uid)
|
260
|
+
return if task_uid.nil? && !@raise_on_failure # ok
|
260
261
|
|
261
|
-
SafeIndex.log_or_throw(:
|
262
|
-
@index.
|
262
|
+
SafeIndex.log_or_throw(:wait_for_task, @raise_on_failure) do
|
263
|
+
@index.wait_for_task(task_uid)
|
263
264
|
end
|
264
265
|
end
|
265
266
|
|
@@ -442,7 +443,7 @@ module MeiliSearch
|
|
442
443
|
next if ms_indexing_disabled?(options)
|
443
444
|
|
444
445
|
index = ms_ensure_init(options, settings)
|
445
|
-
|
446
|
+
last_task = nil
|
446
447
|
|
447
448
|
ms_find_in_batches(batch_size) do |group|
|
448
449
|
if ms_conditional_index?(options)
|
@@ -457,9 +458,9 @@ module MeiliSearch
|
|
457
458
|
attributes = attributes.to_hash unless attributes.instance_of?(Hash)
|
458
459
|
attributes.merge ms_pk(options) => ms_primary_key_of(d, options)
|
459
460
|
end
|
460
|
-
|
461
|
+
last_task = index.add_documents(documents)
|
461
462
|
end
|
462
|
-
index.
|
463
|
+
index.wait_for_task(last_task['uid']) if last_task && (synchronous || options[:synchronous])
|
463
464
|
end
|
464
465
|
nil
|
465
466
|
end
|
@@ -474,8 +475,8 @@ module MeiliSearch
|
|
474
475
|
end
|
475
476
|
|
476
477
|
index = SafeIndex.new(ms_index_uid(options), true, options)
|
477
|
-
|
478
|
-
index.
|
478
|
+
task = index.update_settings(final_settings)
|
479
|
+
index.wait_for_task(task['uid']) if synchronous
|
479
480
|
end
|
480
481
|
end
|
481
482
|
|
@@ -484,8 +485,8 @@ module MeiliSearch
|
|
484
485
|
next if ms_indexing_disabled?(options)
|
485
486
|
|
486
487
|
index = ms_ensure_init(options, settings)
|
487
|
-
|
488
|
-
index.
|
488
|
+
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
490
|
end
|
490
491
|
end
|
491
492
|
|
@@ -566,7 +567,7 @@ module MeiliSearch
|
|
566
567
|
end
|
567
568
|
|
568
569
|
index = ms_index(index_uid)
|
569
|
-
index.search(q, params.
|
570
|
+
index.search(q, params.to_h { |k, v| [k, v] })
|
570
571
|
end
|
571
572
|
|
572
573
|
module AdditionalMethods
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meilisearch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Meili
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|