meilisearch 0.30.0 → 0.31.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5efbe9d158037686df9b8bb37bf42e99646abeaae9bb8134a795507c84887c5d
4
- data.tar.gz: 7552001f2cb4030e09588d0601e49ae0d82c5858a31ea491740374251bbf5fd8
3
+ metadata.gz: d6cedcf8f0f86e12bfaee3c4f1464af380f1b6df1943746fc2f954aba8aa1090
4
+ data.tar.gz: c387d93dcfbf3fadd5682469c2b0aab284603afbfa503d77fc9ee674966a724a
5
5
  SHA512:
6
- metadata.gz: ea80d3871ada8d4dcf224893f38ad7a972500df85aabd9100c0772bc9e9aaf3fec9bafa408628357e9d802bfa445307307905b04d4edc656cb8c9808ea307382
7
- data.tar.gz: 742c90c3cbc9d931bf30b7d2d533e1dc577404b55ae4a7f2646a88e2b5a2388eda1f70db742ac3acf44721f22a137c1f1c93adab4fb7287475350850c9fe1e9f
6
+ metadata.gz: fbd5af58608cb342538232663cddc27d073af9aa3d598385c9a227ef615eb556b8c0f0f6195a977fe89ac542b4efd635aae14747a82b21a821c89272ab619b22
7
+ data.tar.gz: 15caa179a6f58ff36d2ec4abf1d9b40f8477ba62cbfe49cf0f3944465ed1a2b2c8a5cdc69ab15f9ecc42ca525ce6b553adc17444727adf46d1161ec8b1732e1f
@@ -22,14 +22,14 @@ module Meilisearch
22
22
  @headers = build_default_options_headers
23
23
  end
24
24
 
25
- def http_get(relative_path = '', query_params = {})
25
+ def http_get(relative_path = '', query_params = {}, options = {})
26
26
  send_request(
27
27
  proc { |path, config| self.class.get(path, config) },
28
28
  relative_path,
29
29
  config: {
30
30
  query_params: query_params,
31
- headers: remove_headers(@headers.dup, 'Content-Type'),
32
- options: @options
31
+ headers: remove_headers(@headers.dup.merge(options[:headers] || {}), 'Content-Type'),
32
+ options: @options.merge(options)
33
33
  }
34
34
  )
35
35
  end
@@ -47,40 +47,40 @@ module Meilisearch
47
47
  )
48
48
  end
49
49
 
50
- def http_put(relative_path = '', body = nil, query_params = nil)
50
+ def http_put(relative_path = '', body = nil, query_params = nil, options = {})
51
51
  send_request(
52
52
  proc { |path, config| self.class.put(path, config) },
53
53
  relative_path,
54
54
  config: {
55
55
  query_params: query_params,
56
56
  body: body,
57
- headers: @headers,
58
- options: @options
57
+ headers: @headers.dup.merge(options[:headers] || {}),
58
+ options: @options.merge(options)
59
59
  }
60
60
  )
61
61
  end
62
62
 
63
- def http_patch(relative_path = '', body = nil, query_params = nil)
63
+ def http_patch(relative_path = '', body = nil, query_params = nil, options = {})
64
64
  send_request(
65
65
  proc { |path, config| self.class.patch(path, config) },
66
66
  relative_path,
67
67
  config: {
68
68
  query_params: query_params,
69
69
  body: body,
70
- headers: @headers,
71
- options: @options
70
+ headers: @headers.dup.merge(options[:headers] || {}),
71
+ options: @options.merge(options)
72
72
  }
73
73
  )
74
74
  end
75
75
 
76
- def http_delete(relative_path = '', query_params = nil)
76
+ def http_delete(relative_path = '', query_params = nil, options = {})
77
77
  send_request(
78
78
  proc { |path, config| self.class.delete(path, config) },
79
79
  relative_path,
80
80
  config: {
81
81
  query_params: query_params,
82
- headers: remove_headers(@headers.dup, 'Content-Type'),
83
- options: @options
82
+ headers: remove_headers(@headers.dup.merge(options[:headers] || {}), 'Content-Type'),
83
+ options: @options.merge(options)
84
84
  }
85
85
  )
86
86
  end
@@ -145,6 +145,48 @@ module Meilisearch
145
145
  end
146
146
  alias add_or_update_documents update_documents
147
147
 
148
+ def update_documents_json(documents, primary_key = nil)
149
+ options = { convert_body?: false }
150
+ response = http_put "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact, options
151
+
152
+ Models::Task.new(response, task_endpoint)
153
+ end
154
+ alias add_or_update_documents_json update_documents_json
155
+
156
+ def update_documents_ndjson(documents, primary_key = nil)
157
+ options = { headers: { 'Content-Type' => 'application/x-ndjson' }, convert_body?: false }
158
+ response = http_put "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact, options
159
+
160
+ Models::Task.new(response, task_endpoint)
161
+ end
162
+ alias add_or_update_documents_ndjson update_documents_ndjson
163
+
164
+ def update_documents_csv(documents, primary_key = nil, delimiter = nil)
165
+ options = { headers: { 'Content-Type' => 'text/csv' }, convert_body?: false }
166
+
167
+ response = http_put "/indexes/#{@uid}/documents", documents, {
168
+ primaryKey: primary_key,
169
+ csvDelimiter: delimiter
170
+ }.compact, options
171
+
172
+ Models::Task.new(response, task_endpoint)
173
+ end
174
+ alias add_or_update_documents_csv add_documents_csv
175
+
176
+ def update_documents_ndjson_in_batches(documents, batch_size = 1000, primary_key = nil)
177
+ documents.lines.each_slice(batch_size).map do |batch|
178
+ update_documents_ndjson(batch.join, primary_key)
179
+ end
180
+ end
181
+
182
+ def update_documents_csv_in_batches(documents, batch_size = 1000, primary_key = nil, delimiter = nil)
183
+ lines = documents.lines
184
+ heading = lines.first
185
+ lines.drop(1).each_slice(batch_size).map do |batch|
186
+ update_documents_csv(heading + batch.join, primary_key, delimiter)
187
+ end
188
+ end
189
+
148
190
  def update_documents!(documents, primary_key = nil)
149
191
  Utils.soft_deprecate(
150
192
  'Index#update_documents!',
@@ -161,6 +203,20 @@ module Meilisearch
161
203
  end
162
204
  end
163
205
 
206
+ def add_documents_ndjson_in_batches(documents, batch_size = 1000, primary_key = nil)
207
+ documents.lines.each_slice(batch_size).map do |batch|
208
+ add_documents_ndjson(batch.join, primary_key)
209
+ end
210
+ end
211
+
212
+ def add_documents_csv_in_batches(documents, batch_size = 1000, primary_key = nil, delimiter = nil)
213
+ lines = documents.lines
214
+ heading = lines.first
215
+ lines.drop(1).each_slice(batch_size).map do |batch|
216
+ add_documents_csv(heading + batch.join, primary_key, delimiter)
217
+ end
218
+ end
219
+
164
220
  def add_documents_in_batches!(documents, batch_size = 1000, primary_key = nil)
165
221
  Utils.soft_deprecate(
166
222
  'Index#add_documents_in_batches!',
@@ -609,11 +665,15 @@ module Meilisearch
609
665
  end
610
666
 
611
667
  def update_proximity_precision(proximity_precision_attribute)
612
- http_put("/indexes/#{@uid}/settings/proximity-precision", proximity_precision_attribute)
668
+ response = http_put("/indexes/#{@uid}/settings/proximity-precision", proximity_precision_attribute)
669
+
670
+ Models::Task.new(response, task_endpoint)
613
671
  end
614
672
 
615
673
  def reset_proximity_precision
616
- http_delete("/indexes/#{@uid}/settings/proximity-precision")
674
+ response = http_delete("/indexes/#{@uid}/settings/proximity-precision")
675
+
676
+ Models::Task.new(response, task_endpoint)
617
677
  end
618
678
 
619
679
  ### SETTINGS - SEARCH CUTOFF MS
@@ -623,11 +683,15 @@ module Meilisearch
623
683
  end
624
684
 
625
685
  def update_search_cutoff_ms(search_cutoff_ms_attribute)
626
- http_put("/indexes/#{@uid}/settings/search-cutoff-ms", search_cutoff_ms_attribute)
686
+ response = http_put("/indexes/#{@uid}/settings/search-cutoff-ms", search_cutoff_ms_attribute)
687
+
688
+ Models::Task.new(response, task_endpoint)
627
689
  end
628
690
 
629
691
  def reset_search_cutoff_ms
630
- http_delete("/indexes/#{@uid}/settings/search-cutoff-ms")
692
+ response = http_delete("/indexes/#{@uid}/settings/search-cutoff-ms")
693
+
694
+ Models::Task.new(response, task_endpoint)
631
695
  end
632
696
 
633
697
  ### SETTINGS - LOCALIZED ATTRIBUTES
@@ -639,11 +703,15 @@ module Meilisearch
639
703
  def update_localized_attributes(new_localized_attributes)
640
704
  new_localized_attributes = Utils.transform_attributes(new_localized_attributes)
641
705
 
642
- http_put("/indexes/#{@uid}/settings/localized-attributes", new_localized_attributes)
706
+ response = http_put("/indexes/#{@uid}/settings/localized-attributes", new_localized_attributes)
707
+
708
+ Models::Task.new(response, task_endpoint)
643
709
  end
644
710
 
645
711
  def reset_localized_attributes
646
- http_delete("/indexes/#{@uid}/settings/localized-attributes")
712
+ response = http_delete("/indexes/#{@uid}/settings/localized-attributes")
713
+
714
+ Models::Task.new(response, task_endpoint)
647
715
  end
648
716
 
649
717
  ### SETTINGS - FACET SEARCH
@@ -653,11 +721,15 @@ module Meilisearch
653
721
  end
654
722
 
655
723
  def update_facet_search_setting(new_facet_search_setting)
656
- http_put("/indexes/#{@uid}/settings/facet-search", new_facet_search_setting)
724
+ response = http_put("/indexes/#{@uid}/settings/facet-search", new_facet_search_setting)
725
+
726
+ Models::Task.new(response, task_endpoint)
657
727
  end
658
728
 
659
729
  def reset_facet_search_setting
660
- http_delete("/indexes/#{@uid}/settings/facet-search")
730
+ response = http_delete("/indexes/#{@uid}/settings/facet-search")
731
+
732
+ Models::Task.new(response, task_endpoint)
661
733
  end
662
734
 
663
735
  ### SETTINGS - PREFIX SEARCH
@@ -667,11 +739,15 @@ module Meilisearch
667
739
  end
668
740
 
669
741
  def update_prefix_search(new_prefix_search_setting)
670
- http_put("/indexes/#{@uid}/settings/prefix-search", new_prefix_search_setting)
742
+ response = http_put("/indexes/#{@uid}/settings/prefix-search", new_prefix_search_setting)
743
+
744
+ Models::Task.new(response, task_endpoint)
671
745
  end
672
746
 
673
747
  def reset_prefix_search
674
- http_delete("/indexes/#{@uid}/settings/prefix-search")
748
+ response = http_delete("/indexes/#{@uid}/settings/prefix-search")
749
+
750
+ Models::Task.new(response, task_endpoint)
675
751
  end
676
752
 
677
753
  ### SETTINGS - EMBEDDERS
@@ -683,11 +759,15 @@ module Meilisearch
683
759
  def update_embedders(new_embedders)
684
760
  new_embedders = Utils.transform_attributes(new_embedders)
685
761
 
686
- http_patch("/indexes/#{@uid}/settings/embedders", new_embedders)
762
+ response = http_patch("/indexes/#{@uid}/settings/embedders", new_embedders)
763
+
764
+ Models::Task.new(response, task_endpoint)
687
765
  end
688
766
 
689
767
  def reset_embedders
690
- http_delete("/indexes/#{@uid}/settings/embedders")
768
+ response = http_delete("/indexes/#{@uid}/settings/embedders")
769
+
770
+ Models::Task.new(response, task_endpoint)
691
771
  end
692
772
  end
693
773
  end
@@ -2,10 +2,20 @@
2
2
 
3
3
  module Meilisearch
4
4
  module MultiSearch
5
- def multi_search(data)
6
- body = Utils.transform_attributes(data)
5
+ # Performs search on one or more indexes
6
+ #
7
+ # @param [Hash] federation_options
8
+ # - `limit`: number of results in the merged list
9
+ # - `offset`: number of results to skip in the merged list
10
+ def multi_search(data = nil, queries: [], federation: nil)
11
+ Utils.soft_deprecate('multi_search([])', 'multi_search(queries: [])') if data
7
12
 
8
- http_post '/multi-search', queries: body
13
+ queries += data if data
14
+
15
+ queries = Utils.transform_attributes(queries)
16
+ federation = Utils.transform_attributes(federation)
17
+
18
+ http_post '/multi-search', queries: queries, federation: federation
9
19
  end
10
20
  end
11
21
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meilisearch
4
- VERSION = '0.30.0'
4
+ VERSION = '0.31.0'
5
5
 
6
6
  def self.qualified_version
7
7
  "Meilisearch Ruby (v#{VERSION})"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meilisearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.0
4
+ version: 0.31.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meili
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-10 00:00:00.000000000 Z
11
+ date: 2025-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.17'
19
+ version: '0.22'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.17'
26
+ version: '0.22'
27
27
  description: An easy-to-use ruby client for Meilisearch API. See https://github.com/meilisearch/meilisearch
28
28
  email: bonjour@meilisearch.com
29
29
  executables: []