meilisearch 0.29.0 → 0.30.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07ebab8519a40f392916e9b9f52a48002121c781dd8a2c7ab666e4c39adb0f9e
4
- data.tar.gz: 30087e85e8b2dad33b89d8006c3730c5493f9177ffb33db589fe779ac2dc3adf
3
+ metadata.gz: 5efbe9d158037686df9b8bb37bf42e99646abeaae9bb8134a795507c84887c5d
4
+ data.tar.gz: 7552001f2cb4030e09588d0601e49ae0d82c5858a31ea491740374251bbf5fd8
5
5
  SHA512:
6
- metadata.gz: 5b36ec117ea1fef77e1c862b2cb877a5d29e52f7924a7aa1a8215c5e613b6e3952182d4de979ad79aa69823655f2cbb43c1e11c392185fe65864566b5f269292
7
- data.tar.gz: e4303f28920e02647de29c739f37217e8980e80d7e7266ec4c562d7f4dab3007eb18a32094e8e03c3f28649c9ca7a8a0b045bc5485cbf3d6cf93ea6123262cd0
6
+ metadata.gz: ea80d3871ada8d4dcf224893f38ad7a972500df85aabd9100c0772bc9e9aaf3fec9bafa408628357e9d802bfa445307307905b04d4edc656cb8c9808ea307382
7
+ data.tar.gz: 742c90c3cbc9d931bf30b7d2d533e1dc577404b55ae4a7f2646a88e2b5a2388eda1f70db742ac3acf44721f22a137c1f1c93adab4fb7287475350850c9fe1e9f
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019-2024 Meili SAS
3
+ Copyright (c) 2019-2025 Meili SAS
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -33,7 +33,6 @@
33
33
  ## Table of Contents <!-- omit in TOC -->
34
34
 
35
35
  - [📖 Documentation](#-documentation)
36
- - [⚡ Supercharge your Meilisearch experience](#-supercharge-your-meilisearch-experience)
37
36
  - [🔧 Installation](#-installation)
38
37
  - [🚀 Getting started](#-getting-started)
39
38
  - [🤖 Compatibility with Meilisearch](#-compatibility-with-meilisearch)
@@ -47,10 +46,6 @@ This readme contains all the documentation you need to start using this Meilisea
47
46
  For general information on how to use Meilisearch—such as our API reference, tutorials, guides, and in-depth articles—refer to our [main documentation website](https://www.meilisearch.com/docs/).
48
47
 
49
48
 
50
- ## ⚡ Supercharge your Meilisearch experience
51
-
52
- Say goodbye to server deployment and manual updates with [Meilisearch Cloud](https://www.meilisearch.com/cloud?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-ruby). Get started with a 14-day free trial! No credit card required.
53
-
54
49
  ## 🔧 Installation
55
50
 
56
51
  We officially support any version of Ruby that is still receiving at least [security maintenance](https://www.ruby-lang.org/en/downloads/branches/). You may, however, be fine with any Ruby version above 3.0.
@@ -70,19 +65,9 @@ gem 'meilisearch'
70
65
 
71
66
  ### Run Meilisearch <!-- omit in toc -->
72
67
 
73
- There are many easy ways to [download and run a Meilisearch instance](https://www.meilisearch.com/docs/learn/getting_started/quick_start#setup-and-installation).
74
-
75
- For example, using the `curl` command in your [Terminal](https://itconnect.uw.edu/learn/workshops/online-tutorials/what-is-a-terminal/):
76
-
77
- ```sh
78
- # Install Meilisearch
79
- curl -L https://install.meilisearch.com | sh
80
-
81
- # Launch Meilisearch
82
- ./meilisearch --master-key=masterKey
83
- ```
68
+ ⚡️ **Launch, scale, and streamline in minutes with Meilisearch Cloud**—no maintenance, no commitment, cancel anytime. [Try it free now](https://cloud.meilisearch.com/login?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-ruby).
84
69
 
85
- NB: you can also download Meilisearch from **Homebrew** or **APT** or even run it using **Docker**.
70
+ 🪨 Prefer to self-host? [Download and deploy](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-ruby) our fast, open-source search engine on your own infrastructure.
86
71
 
87
72
  ## 🚀 Getting started
88
73
 
@@ -91,7 +76,7 @@ NB: you can also download Meilisearch from **Homebrew** or **APT** or even run i
91
76
  ```ruby
92
77
  require 'meilisearch'
93
78
 
94
- client = MeiliSearch::Client.new('http://127.0.0.1:7700', 'masterKey')
79
+ client = Meilisearch::Client.new('http://127.0.0.1:7700', 'masterKey')
95
80
 
96
81
  # An index is where the documents are stored.
97
82
  index = client.index('movies')
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module MeiliSearch
3
+ module Meilisearch
4
4
  class Client < HTTPRequest
5
- include MeiliSearch::TenantToken
6
- include MeiliSearch::MultiSearch
5
+ include Meilisearch::TenantToken
6
+ include Meilisearch::MultiSearch
7
7
 
8
8
  ### INDEXES
9
9
 
@@ -157,6 +157,16 @@ module MeiliSearch
157
157
  task_endpoint.wait_for_task(task_uid, timeout_in_ms, interval_in_ms)
158
158
  end
159
159
 
160
+ ### BATCHES
161
+
162
+ def batches(options = {})
163
+ http_get '/batches', options
164
+ end
165
+
166
+ def batch(batch_uid)
167
+ http_get "/batches/#{batch_uid}"
168
+ end
169
+
160
170
  private
161
171
 
162
172
  def index_object(uid, primary_key = nil)
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module MeiliSearch
3
+ module Meilisearch
4
4
  class Error < StandardError
5
5
  end
6
6
 
7
7
  class ApiError < Error
8
8
  # :http_code # e.g. 400, 404...
9
9
  # :http_message # e.g. Bad Request, Not Found...
10
- # :http_body # The response body received from the MeiliSearch API
11
- # :ms_code # The error code given by the MeiliSearch API
12
- # :ms_type # The error type given by the MeiliSearch API
13
- # :ms_link # The documentation link given by the MeiliSearch API
14
- # :ms_message # The error message given by the MeiliSearch API
10
+ # :http_body # The response body received from the Meilisearch API
11
+ # :ms_code # The error code given by the Meilisearch API
12
+ # :ms_type # The error type given by the Meilisearch API
13
+ # :ms_link # The documentation link given by the Meilisearch API
14
+ # :ms_message # The error message given by the Meilisearch API
15
15
  # :message # The detailed error message of this error class
16
16
 
17
17
  attr_reader :http_code, :http_message, :http_body, :ms_code, :ms_type, :ms_link, :ms_message, :message
@@ -26,7 +26,7 @@ module MeiliSearch
26
26
  @http_body = parse_body(http_body)
27
27
  @ms_code = @http_body['code']
28
28
  @ms_type = @http_body['type']
29
- @ms_message = @http_body.fetch('message', 'MeiliSearch API has not returned any error message')
29
+ @ms_message = @http_body.fetch('message', 'Meilisearch API has not returned any error message')
30
30
  @ms_link = @http_body.fetch('link', '<no documentation link found>')
31
31
  @message = "#{http_code} #{http_message} - #{@ms_message}. See #{ms_link}."
32
32
  super(details)
@@ -41,14 +41,14 @@ module MeiliSearch
41
41
  {}
42
42
  end
43
43
  rescue JSON::ParserError
44
- # We might receive a JSON::ParserError when, for example, MeiliSearch is running behind
44
+ # We might receive a JSON::ParserError when, for example, Meilisearch is running behind
45
45
  # some proxy (ELB or Nginx, for example), and the request timeouts, returning us
46
46
  # a raw HTML body instead of a JSON as we were expecting
47
47
  { 'message' => "The server has not returned a valid JSON HTTP body: #{http_body}" }
48
48
  end
49
49
 
50
50
  def details
51
- "MeiliSearch::ApiError - code: #{@ms_code} - type: #{ms_type} - message: #{@ms_message} - link: #{ms_link}"
51
+ "Meilisearch::ApiError - code: #{@ms_code} - type: #{ms_type} - message: #{@ms_message} - link: #{ms_link}"
52
52
  end
53
53
  end
54
54
 
@@ -56,7 +56,7 @@ module MeiliSearch
56
56
  attr_reader :message
57
57
 
58
58
  def initialize(message)
59
- @message = "An error occurred while trying to connect to the MeiliSearch instance: #{message}"
59
+ @message = "An error occurred while trying to connect to the Meilisearch instance: #{message}"
60
60
  super(@message)
61
61
  end
62
62
  end
@@ -80,8 +80,8 @@ module MeiliSearch
80
80
  end
81
81
 
82
82
  module TenantToken
83
- class ExpireOrInvalidSignature < MeiliSearch::Error; end
84
- class InvalidApiKey < MeiliSearch::Error; end
85
- class InvalidSearchRules < MeiliSearch::Error; end
83
+ class ExpireOrInvalidSignature < Meilisearch::Error; end
84
+ class InvalidApiKey < Meilisearch::Error; end
85
+ class InvalidSearchRules < Meilisearch::Error; end
86
86
  end
87
87
  end
@@ -3,7 +3,7 @@
3
3
  require 'httparty'
4
4
  require 'meilisearch/error'
5
5
 
6
- module MeiliSearch
6
+ module Meilisearch
7
7
  class HTTPRequest
8
8
  include HTTParty
9
9
 
@@ -93,7 +93,7 @@ module MeiliSearch
93
93
  'Authorization' => ("Bearer #{@api_key}" unless @api_key.nil?),
94
94
  'User-Agent' => [
95
95
  @options.fetch(:client_agents, []),
96
- MeiliSearch.qualified_version
96
+ Meilisearch.qualified_version
97
97
  ].flatten.join(';')
98
98
  }.compact
99
99
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'meilisearch/http_request'
4
4
 
5
- module MeiliSearch
5
+ module Meilisearch
6
6
  class Index < HTTPRequest
7
7
  attr_reader :uid, :primary_key, :created_at, :updated_at
8
8
 
@@ -185,6 +185,18 @@ module MeiliSearch
185
185
  update_documents_in_batches(documents, batch_size, primary_key).each(&:await)
186
186
  end
187
187
 
188
+ # Update documents by function
189
+ #
190
+ # options - A Hash containing the function string and related options
191
+ # context:
192
+ # filter:
193
+ # function:
194
+ def update_documents_by_function(options)
195
+ response = http_post "/indexes/#{@uid}/documents/edit", options
196
+
197
+ Models::Task.new(response, task_endpoint)
198
+ end
199
+
188
200
  # Public: Delete documents from an index
189
201
  #
190
202
  # options: A Hash or an Array containing documents_ids or a hash with filter:.
@@ -221,7 +233,7 @@ module MeiliSearch
221
233
 
222
234
  def delete_document(document_id)
223
235
  if document_id.nil? || document_id.to_s.empty?
224
- raise MeiliSearch::InvalidDocumentId, 'document_id cannot be empty or nil'
236
+ raise Meilisearch::InvalidDocumentId, 'document_id cannot be empty or nil'
225
237
  end
226
238
 
227
239
  encode_document = URI.encode_www_form_component(document_id)
@@ -617,5 +629,65 @@ module MeiliSearch
617
629
  def reset_search_cutoff_ms
618
630
  http_delete("/indexes/#{@uid}/settings/search-cutoff-ms")
619
631
  end
632
+
633
+ ### SETTINGS - LOCALIZED ATTRIBUTES
634
+
635
+ def localized_attributes
636
+ http_get("/indexes/#{@uid}/settings/localized-attributes")
637
+ end
638
+
639
+ def update_localized_attributes(new_localized_attributes)
640
+ new_localized_attributes = Utils.transform_attributes(new_localized_attributes)
641
+
642
+ http_put("/indexes/#{@uid}/settings/localized-attributes", new_localized_attributes)
643
+ end
644
+
645
+ def reset_localized_attributes
646
+ http_delete("/indexes/#{@uid}/settings/localized-attributes")
647
+ end
648
+
649
+ ### SETTINGS - FACET SEARCH
650
+
651
+ def facet_search_setting
652
+ http_get("/indexes/#{@uid}/settings/facet-search")
653
+ end
654
+
655
+ def update_facet_search_setting(new_facet_search_setting)
656
+ http_put("/indexes/#{@uid}/settings/facet-search", new_facet_search_setting)
657
+ end
658
+
659
+ def reset_facet_search_setting
660
+ http_delete("/indexes/#{@uid}/settings/facet-search")
661
+ end
662
+
663
+ ### SETTINGS - PREFIX SEARCH
664
+
665
+ def prefix_search
666
+ http_get("/indexes/#{@uid}/settings/prefix-search")
667
+ end
668
+
669
+ def update_prefix_search(new_prefix_search_setting)
670
+ http_put("/indexes/#{@uid}/settings/prefix-search", new_prefix_search_setting)
671
+ end
672
+
673
+ def reset_prefix_search
674
+ http_delete("/indexes/#{@uid}/settings/prefix-search")
675
+ end
676
+
677
+ ### SETTINGS - EMBEDDERS
678
+
679
+ def embedders
680
+ http_get("/indexes/#{@uid}/settings/embedders")
681
+ end
682
+
683
+ def update_embedders(new_embedders)
684
+ new_embedders = Utils.transform_attributes(new_embedders)
685
+
686
+ http_patch("/indexes/#{@uid}/settings/embedders", new_embedders)
687
+ end
688
+
689
+ def reset_embedders
690
+ http_delete("/indexes/#{@uid}/settings/embedders")
691
+ end
620
692
  end
621
693
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'forwardable'
4
4
 
5
- module MeiliSearch
5
+ module Meilisearch
6
6
  module Models
7
7
  class Task
8
8
  extend Forwardable
@@ -88,7 +88,7 @@ module MeiliSearch
88
88
  self.metadata = with || @task_endpoint.task(uid)
89
89
 
90
90
  self
91
- rescue MeiliSearch::ApiError => e
91
+ rescue Meilisearch::ApiError => e
92
92
  raise e unless e.http_code == 404
93
93
 
94
94
  @deleted = true
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module MeiliSearch
3
+ module Meilisearch
4
4
  module MultiSearch
5
5
  def multi_search(data)
6
6
  body = Utils.transform_attributes(data)
@@ -3,12 +3,12 @@
3
3
  require 'meilisearch/http_request'
4
4
  require 'timeout'
5
5
 
6
- module MeiliSearch
6
+ module Meilisearch
7
7
  class Task < HTTPRequest
8
8
  ALLOWED_PARAMS = [
9
9
  :limit, :from, :index_uids, :types, :statuses, :uids, :canceled_by,
10
10
  :before_enqueued_at, :after_enqueued_at, :before_started_at, :after_started_at,
11
- :before_finished_at, :after_finished_at
11
+ :before_finished_at, :after_finished_at, :reverse
12
12
  ].freeze
13
13
  ALLOWED_CANCELATION_PARAMS = (ALLOWED_PARAMS - [:limit, :from]).freeze
14
14
 
@@ -46,7 +46,7 @@ module MeiliSearch
46
46
  end
47
47
  end
48
48
  rescue Timeout::Error
49
- raise MeiliSearch::TimeoutError
49
+ raise Meilisearch::TimeoutError
50
50
  end
51
51
 
52
52
  private
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module MeiliSearch
3
+ module Meilisearch
4
4
  module TenantToken
5
5
  HEADER = {
6
6
  typ: 'JWT',
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'logger'
4
4
 
5
- module MeiliSearch
5
+ module Meilisearch
6
6
  module Utils
7
7
  SNAKE_CASE = /[^a-zA-Z0-9]+(.)/
8
8
 
@@ -57,10 +57,10 @@ module MeiliSearch
57
57
 
58
58
  def version_error_handler(method_name)
59
59
  yield if block_given?
60
- rescue MeiliSearch::ApiError => e
60
+ rescue Meilisearch::ApiError => e
61
61
  message = message_builder(e.http_message, method_name)
62
62
 
63
- raise MeiliSearch::ApiError.new(e.http_code, message, e.http_body)
63
+ raise Meilisearch::ApiError.new(e.http_code, message, e.http_body)
64
64
  rescue StandardError => e
65
65
  raise e.class, message_builder(e.message, method_name)
66
66
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module MeiliSearch
4
- VERSION = '0.29.0'
3
+ module Meilisearch
4
+ VERSION = '0.30.0'
5
5
 
6
6
  def self.qualified_version
7
7
  "Meilisearch Ruby (v#{VERSION})"
data/lib/meilisearch.rb CHANGED
@@ -12,5 +12,40 @@ require 'meilisearch/task'
12
12
  require 'meilisearch/client'
13
13
  require 'meilisearch/index'
14
14
 
15
+ module Meilisearch
16
+ end
17
+
18
+ # Softly deprecate the old spelling of the top level module
19
+ # from MeiliSearch to Meilisearch
15
20
  module MeiliSearch
21
+ class << self
22
+ def const_missing(const_name)
23
+ _warn_about_deprecation
24
+
25
+ Meilisearch.const_get(const_name)
26
+ end
27
+
28
+ def method_missing(method_name, *args, **kwargs)
29
+ _warn_about_deprecation
30
+
31
+ Meilisearch.send(method_name, *args, **kwargs)
32
+ end
33
+
34
+ def respond_to_missing?(method_name, *)
35
+ Meilisearch.respond_to?(method_name) || super
36
+ end
37
+
38
+ private
39
+
40
+ def _warn_about_deprecation
41
+ return if @warned
42
+
43
+ Meilisearch::Utils.logger.warn <<~RENAMED_MODULE_WARNING
44
+ [meilisearch-ruby] The top-level module of Meilisearch has been renamed.
45
+ [meilisearch-ruby] Please update "MeiliSearch" to "Meilisearch".
46
+ RENAMED_MODULE_WARNING
47
+
48
+ @warned = true
49
+ end
50
+ end
16
51
  end
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.29.0
4
+ version: 0.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meili
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-28 00:00:00.000000000 Z
11
+ date: 2025-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty