meilisearch 0.25.1 → 0.27.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: 64423a34ad9823417a67cf271103db76b41c3895470dbd13a1c90d986792d439
4
- data.tar.gz: 1bc5ba4774f7704cc6aefed0458dab6de7f4a4c0b4e45c9bb762b4843fc7c5ed
3
+ metadata.gz: 41cfeec247ef2cdaef19f6ddade5d32b7dcc80cbc69fe500c9310f7dab87e5a4
4
+ data.tar.gz: af889a896d762a38fbb1af56aba3b462cf73f35e4fe97048ef09bbaad44ffa53
5
5
  SHA512:
6
- metadata.gz: 37800a57fffe10aa250adf14af4b34855af7281c4adc7b4c0b62b573ad87ff365095493be04b56c2451de79aac20533625738bee98f70c5c124302bfe6172096
7
- data.tar.gz: b15bb586f86ba17e6b7546b246380458c1573c3c2c038e00610e2e83b1ad08dbf06293cdb1180cf309ee4317f0441f0df5edc08273d3f1ffe3b363e8acc09fe1
6
+ metadata.gz: 6ce24688fe857e840d07efda981cc00d0f8a60982aea1d487646b21a82117693eaa61fbe9dc778512b00b7d2363001c68dca0387f7b7a550a00eee022133c046
7
+ data.tar.gz: fda38ae00c08ba533e76dc0ce9a101331b23fb47e6c9554478a6027f1524b92141c6ecc764dce974402e66db67b9e6d85a96ff74893eb3419d0a9f02865b1cec
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019-2022 Meili SAS
3
+ Copyright (c) 2019-2024 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
@@ -30,7 +30,7 @@
30
30
 
31
31
  **Meilisearch** is an open-source search engine. [Learn more about Meilisearch.](https://github.com/meilisearch/meilisearch)
32
32
 
33
- ## Table of Contents <!-- omit in toc -->
33
+ ## Table of Contents <!-- omit in TOC -->
34
34
 
35
35
  - [📖 Documentation](#-documentation)
36
36
  - [⚡ Supercharge your Meilisearch experience](#-supercharge-your-meilisearch-experience)
@@ -53,7 +53,7 @@ Say goodbye to server deployment and manual updates with [Meilisearch Cloud](htt
53
53
 
54
54
  ## 🔧 Installation
55
55
 
56
- This package requires Ruby version 2.6.0 or later.
56
+ This package requires Ruby version 3.0.0 or later.
57
57
 
58
58
  With `gem` in command line:
59
59
  ```bash
@@ -121,6 +121,12 @@ module MeiliSearch
121
121
  http_post '/dumps'
122
122
  end
123
123
 
124
+ ### SNAPSHOTS
125
+
126
+ def create_snapshot
127
+ http_post '/snapshots'
128
+ end
129
+
124
130
  ### TASKS
125
131
 
126
132
  def cancel_tasks(options = {})
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MeiliSearch
4
- class ApiError < StandardError
4
+ class Error < StandardError
5
+ end
6
+
7
+ class ApiError < Error
5
8
  # :http_code # e.g. 400, 404...
6
9
  # :http_message # e.g. Bad Request, Not Found...
7
10
  # :http_body # The response body received from the MeiliSearch API
@@ -18,26 +21,30 @@ module MeiliSearch
18
21
  alias link ms_link
19
22
 
20
23
  def initialize(http_code, http_message, http_body)
21
- get_meilisearch_error_info(http_body) unless http_body.nil? || http_body.empty?
22
24
  @http_code = http_code
23
25
  @http_message = http_message
24
- @ms_message ||= 'MeiliSearch API has not returned any error message'
25
- @ms_link ||= '<no documentation link found>'
26
+ @http_body = parse_body(http_body)
27
+ @ms_code = @http_body['code']
28
+ @ms_type = @http_body['type']
29
+ @ms_message = @http_body.fetch('message', 'MeiliSearch API has not returned any error message')
30
+ @ms_link = @http_body.fetch('link', '<no documentation link found>')
26
31
  @message = "#{http_code} #{http_message} - #{@ms_message}. See #{ms_link}."
27
32
  super(details)
28
33
  end
29
34
 
30
- def get_meilisearch_error_info(http_body)
31
- @http_body = JSON.parse(http_body)
32
- @ms_code = @http_body['code']
33
- @ms_message = @http_body['message']
34
- @ms_type = @http_body['type']
35
- @ms_link = @http_body['link']
35
+ def parse_body(http_body)
36
+ if http_body.respond_to?(:to_hash)
37
+ http_body.to_hash
38
+ elsif http_body.respond_to?(:to_str)
39
+ JSON.parse(http_body.to_str)
40
+ else
41
+ {}
42
+ end
36
43
  rescue JSON::ParserError
37
44
  # We might receive a JSON::ParserError when, for example, MeiliSearch is running behind
38
45
  # some proxy (ELB or Nginx, for example), and the request timeouts, returning us
39
46
  # a raw HTML body instead of a JSON as we were expecting
40
- @ms_message = "The server has not returned a valid JSON HTTP body: #{http_body}"
47
+ { 'message' => "The server has not returned a valid JSON HTTP body: #{http_body}" }
41
48
  end
42
49
 
43
50
  def details
@@ -45,7 +52,7 @@ module MeiliSearch
45
52
  end
46
53
  end
47
54
 
48
- class CommunicationError < StandardError
55
+ class CommunicationError < Error
49
56
  attr_reader :message
50
57
 
51
58
  def initialize(message)
@@ -54,7 +61,7 @@ module MeiliSearch
54
61
  end
55
62
  end
56
63
 
57
- class TimeoutError < StandardError
64
+ class TimeoutError < Error
58
65
  attr_reader :message
59
66
 
60
67
  def initialize(message = nil)
@@ -64,8 +71,8 @@ module MeiliSearch
64
71
  end
65
72
 
66
73
  module TenantToken
67
- class ExpireOrInvalidSignature < StandardError; end
68
- class InvalidApiKey < StandardError; end
69
- class InvalidSearchRules < StandardError; end
74
+ class ExpireOrInvalidSignature < MeiliSearch::Error; end
75
+ class InvalidApiKey < MeiliSearch::Error; end
76
+ class InvalidSearchRules < MeiliSearch::Error; end
70
77
  end
71
78
  end
@@ -234,6 +234,15 @@ module MeiliSearch
234
234
  response
235
235
  end
236
236
 
237
+ ### FACET SEARCH
238
+
239
+ def facet_search(name, query = '', **options)
240
+ options.merge!(facet_name: name, facet_query: query)
241
+ options = Utils.transform_attributes(options)
242
+
243
+ http_post("/indexes/#{@uid}/facet-search", options)
244
+ end
245
+
237
246
  ### TASKS
238
247
 
239
248
  def task_endpoint
@@ -461,5 +470,63 @@ module MeiliSearch
461
470
  def reset_faceting
462
471
  http_delete("/indexes/#{@uid}/settings/faceting")
463
472
  end
473
+
474
+ ### SETTINGS - DICTIONARY
475
+
476
+ def dictionary
477
+ http_get("/indexes/#{@uid}/settings/dictionary")
478
+ end
479
+
480
+ def update_dictionary(dictionary_attributes)
481
+ attributes = Utils.transform_attributes(dictionary_attributes)
482
+ http_put("/indexes/#{@uid}/settings/dictionary", attributes)
483
+ end
484
+
485
+ def reset_dictionary
486
+ http_delete("/indexes/#{@uid}/settings/dictionary")
487
+ end
488
+ ### SETTINGS - SEPARATOR TOKENS
489
+
490
+ def separator_tokens
491
+ http_get("/indexes/#{@uid}/settings/separator-tokens")
492
+ end
493
+
494
+ def update_separator_tokens(separator_tokens_attributes)
495
+ attributes = Utils.transform_attributes(separator_tokens_attributes)
496
+ http_put("/indexes/#{@uid}/settings/separator-tokens", attributes)
497
+ end
498
+
499
+ def reset_separator_tokens
500
+ http_delete("/indexes/#{@uid}/settings/separator-tokens")
501
+ end
502
+
503
+ ### SETTINGS - NON SEPARATOR TOKENS
504
+
505
+ def non_separator_tokens
506
+ http_get("/indexes/#{@uid}/settings/non-separator-tokens")
507
+ end
508
+
509
+ def update_non_separator_tokens(non_separator_tokens_attributes)
510
+ attributes = Utils.transform_attributes(non_separator_tokens_attributes)
511
+ http_put("/indexes/#{@uid}/settings/non-separator-tokens", attributes)
512
+ end
513
+
514
+ def reset_non_separator_tokens
515
+ http_delete("/indexes/#{@uid}/settings/non-separator-tokens")
516
+ end
517
+
518
+ ### SETTINGS - PROXIMITY PRECISION
519
+
520
+ def proximity_precision
521
+ http_get("/indexes/#{@uid}/settings/proximity-precision")
522
+ end
523
+
524
+ def update_proximity_precision(proximity_precision_attribute)
525
+ http_put("/indexes/#{@uid}/settings/proximity-precision", proximity_precision_attribute)
526
+ end
527
+
528
+ def reset_proximity_precision
529
+ http_delete("/indexes/#{@uid}/settings/proximity-precision")
530
+ end
464
531
  end
465
532
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module MeiliSearch
4
4
  module Utils
5
- SNAKE_CASE = /[^a-zA-Z0-9]+(.)/.freeze
5
+ SNAKE_CASE = /[^a-zA-Z0-9]+(.)/
6
6
 
7
7
  def self.transform_attributes(body)
8
8
  case body
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MeiliSearch
4
- VERSION = '0.25.1'
4
+ VERSION = '0.27.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.25.1
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meili
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-14 00:00:00.000000000 Z
11
+ date: 2024-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -51,7 +51,8 @@ files:
51
51
  homepage: https://github.com/meilisearch/meilisearch-ruby
52
52
  licenses:
53
53
  - MIT
54
- metadata: {}
54
+ metadata:
55
+ rubygems_mfa_required: 'true'
55
56
  post_install_message:
56
57
  rdoc_options: []
57
58
  require_paths:
@@ -60,14 +61,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
61
  requirements:
61
62
  - - ">="
62
63
  - !ruby/object:Gem::Version
63
- version: 2.6.0
64
+ version: 3.0.0
64
65
  required_rubygems_version: !ruby/object:Gem::Requirement
65
66
  requirements:
66
67
  - - ">="
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0'
69
70
  requirements: []
70
- rubygems_version: 3.0.3.1
71
+ rubygems_version: 3.2.33
71
72
  signing_key:
72
73
  specification_version: 4
73
74
  summary: An easy-to-use ruby client for Meilisearch API