meilisearch 0.15.2 → 0.16.1
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/lib/meilisearch/client.rb +1 -1
 - data/lib/meilisearch/http_request.rb +2 -0
 - data/lib/meilisearch/index.rb +36 -16
 - data/lib/meilisearch/version.rb +1 -1
 - metadata +4 -4
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5c898ee113e0f0a16da0b80ab6b0a079021eaa8ead536da8dfe283b7613dc27a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 29eed6b1c4a3de9efbe54dd766718d70699c5dca5c31dab5b2f901bc5a48c68c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a005a9271b2f926746fee1294a467f2d319af5bbd75677c3532ec4ec2fe6337ac970eda70e55cbaf6584b98235b8e27801088bfa5aff96d111251ce1b5f426a6
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 55fc4b9f2754928d72251c4f88ff5dbb6534d9a209eaa3b1ce5bfd5a39941640f68b3a9c2058eecb0396693bc4b0dfa8708f8c9420700ddd56cd4a40578392e3
         
     | 
    
        data/lib/meilisearch/client.rb
    CHANGED
    
    
    
        data/lib/meilisearch/index.rb
    CHANGED
    
    | 
         @@ -7,10 +7,10 @@ module MeiliSearch 
     | 
|
| 
       7 
7 
     | 
    
         
             
              class Index < HTTPRequest
         
     | 
| 
       8 
8 
     | 
    
         
             
                attr_reader :uid, :primary_key
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
                def initialize(index_uid, url, api_key = nil, primary_key = nil)
         
     | 
| 
      
 10 
     | 
    
         
            +
                def initialize(index_uid, url, api_key = nil, primary_key = nil, options = {})
         
     | 
| 
       11 
11 
     | 
    
         
             
                  @uid = index_uid
         
     | 
| 
       12 
12 
     | 
    
         
             
                  @primary_key = primary_key
         
     | 
| 
       13 
     | 
    
         
            -
                  super(url, api_key)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  super(url, api_key, options)
         
     | 
| 
       14 
14 
     | 
    
         
             
                end
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
                def fetch_info
         
     | 
| 
         @@ -116,7 +116,7 @@ module MeiliSearch 
     | 
|
| 
       116 
116 
     | 
    
         | 
| 
       117 
117 
     | 
    
         
             
                def search(query, options = {})
         
     | 
| 
       118 
118 
     | 
    
         
             
                  parsed_options = options.compact
         
     | 
| 
       119 
     | 
    
         
            -
                  http_post "/indexes/#{@uid}/search", { q: query }.merge(parsed_options)
         
     | 
| 
      
 119 
     | 
    
         
            +
                  http_post "/indexes/#{@uid}/search", { q: query.to_s }.merge(parsed_options)
         
     | 
| 
       120 
120 
     | 
    
         
             
                end
         
     | 
| 
       121 
121 
     | 
    
         | 
| 
       122 
122 
     | 
    
         
             
                ### UPDATES
         
     | 
| 
         @@ -129,11 +129,15 @@ module MeiliSearch 
     | 
|
| 
       129 
129 
     | 
    
         
             
                  http_get "/indexes/#{@uid}/updates"
         
     | 
| 
       130 
130 
     | 
    
         
             
                end
         
     | 
| 
       131 
131 
     | 
    
         | 
| 
      
 132 
     | 
    
         
            +
                def achieved_upate?(update)
         
     | 
| 
      
 133 
     | 
    
         
            +
                  update['status'] != 'enqueued' && update['status'] != 'processing'
         
     | 
| 
      
 134 
     | 
    
         
            +
                end
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
       132 
136 
     | 
    
         
             
                def wait_for_pending_update(update_id, timeout_in_ms = 5000, interval_in_ms = 50)
         
     | 
| 
       133 
137 
     | 
    
         
             
                  Timeout.timeout(timeout_in_ms.to_f / 1000) do
         
     | 
| 
       134 
138 
     | 
    
         
             
                    loop do
         
     | 
| 
       135 
139 
     | 
    
         
             
                      get_update = get_update_status(update_id)
         
     | 
| 
       136 
     | 
    
         
            -
                      return get_update if get_update 
     | 
| 
      
 140 
     | 
    
         
            +
                      return get_update if achieved_upate?(get_update)
         
     | 
| 
       137 
141 
     | 
    
         | 
| 
       138 
142 
     | 
    
         
             
                      sleep interval_in_ms.to_f / 1000
         
     | 
| 
       139 
143 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -160,8 +164,8 @@ module MeiliSearch 
     | 
|
| 
       160 
164 
     | 
    
         
             
                  stats['lastUpdate']
         
     | 
| 
       161 
165 
     | 
    
         
             
                end
         
     | 
| 
       162 
166 
     | 
    
         | 
| 
       163 
     | 
    
         
            -
                def  
     | 
| 
       164 
     | 
    
         
            -
                  stats[' 
     | 
| 
      
 167 
     | 
    
         
            +
                def field_distribution
         
     | 
| 
      
 168 
     | 
    
         
            +
                  stats['fieldDistribution']
         
     | 
| 
       165 
169 
     | 
    
         
             
                end
         
     | 
| 
       166 
170 
     | 
    
         | 
| 
       167 
171 
     | 
    
         
             
                ### SETTINGS - GENERAL
         
     | 
| 
         @@ -220,7 +224,7 @@ module MeiliSearch 
     | 
|
| 
       220 
224 
     | 
    
         
             
                alias get_stop_words stop_words
         
     | 
| 
       221 
225 
     | 
    
         | 
| 
       222 
226 
     | 
    
         
             
                def update_stop_words(stop_words)
         
     | 
| 
       223 
     | 
    
         
            -
                  body = stop_words.is_a?(Array) ? stop_words : [stop_words]
         
     | 
| 
      
 227 
     | 
    
         
            +
                  body = stop_words.nil? || stop_words.is_a?(Array) ? stop_words : [stop_words]
         
     | 
| 
       224 
228 
     | 
    
         
             
                  http_post "/indexes/#{@uid}/settings/stop-words", body
         
     | 
| 
       225 
229 
     | 
    
         
             
                end
         
     | 
| 
       226 
230 
     | 
    
         
             
                alias stop_words= update_stop_words
         
     | 
| 
         @@ -277,20 +281,36 @@ module MeiliSearch 
     | 
|
| 
       277 
281 
     | 
    
         
             
                  http_delete "/indexes/#{@uid}/settings/displayed-attributes"
         
     | 
| 
       278 
282 
     | 
    
         
             
                end
         
     | 
| 
       279 
283 
     | 
    
         | 
| 
       280 
     | 
    
         
            -
                ### SETTINGS - ATTRIBUTES 
     | 
| 
      
 284 
     | 
    
         
            +
                ### SETTINGS - FILTERABLE ATTRIBUTES
         
     | 
| 
      
 285 
     | 
    
         
            +
             
     | 
| 
      
 286 
     | 
    
         
            +
                def filterable_attributes
         
     | 
| 
      
 287 
     | 
    
         
            +
                  http_get "/indexes/#{@uid}/settings/filterable-attributes"
         
     | 
| 
      
 288 
     | 
    
         
            +
                end
         
     | 
| 
      
 289 
     | 
    
         
            +
                alias get_filterable_attributes filterable_attributes
         
     | 
| 
      
 290 
     | 
    
         
            +
             
     | 
| 
      
 291 
     | 
    
         
            +
                def update_filterable_attributes(filterable_attributes)
         
     | 
| 
      
 292 
     | 
    
         
            +
                  http_post "/indexes/#{@uid}/settings/filterable-attributes", filterable_attributes
         
     | 
| 
      
 293 
     | 
    
         
            +
                end
         
     | 
| 
      
 294 
     | 
    
         
            +
                alias filterable_attributes= update_filterable_attributes
         
     | 
| 
      
 295 
     | 
    
         
            +
             
     | 
| 
      
 296 
     | 
    
         
            +
                def reset_filterable_attributes
         
     | 
| 
      
 297 
     | 
    
         
            +
                  http_delete "/indexes/#{@uid}/settings/filterable-attributes"
         
     | 
| 
      
 298 
     | 
    
         
            +
                end
         
     | 
| 
      
 299 
     | 
    
         
            +
             
     | 
| 
      
 300 
     | 
    
         
            +
                ### SETTINGS - SORTABLE ATTRIBUTES
         
     | 
| 
       281 
301 
     | 
    
         | 
| 
       282 
     | 
    
         
            -
                def  
     | 
| 
       283 
     | 
    
         
            -
                  http_get "/indexes/#{@uid}/settings/attributes 
     | 
| 
      
 302 
     | 
    
         
            +
                def sortable_attributes
         
     | 
| 
      
 303 
     | 
    
         
            +
                  http_get "/indexes/#{@uid}/settings/sortable-attributes"
         
     | 
| 
       284 
304 
     | 
    
         
             
                end
         
     | 
| 
       285 
     | 
    
         
            -
                alias  
     | 
| 
      
 305 
     | 
    
         
            +
                alias get_sortable_attributes sortable_attributes
         
     | 
| 
       286 
306 
     | 
    
         | 
| 
       287 
     | 
    
         
            -
                def  
     | 
| 
       288 
     | 
    
         
            -
                  http_post "/indexes/#{@uid}/settings/attributes 
     | 
| 
      
 307 
     | 
    
         
            +
                def update_sortable_attributes(sortable_attributes)
         
     | 
| 
      
 308 
     | 
    
         
            +
                  http_post "/indexes/#{@uid}/settings/sortable-attributes", sortable_attributes
         
     | 
| 
       289 
309 
     | 
    
         
             
                end
         
     | 
| 
       290 
     | 
    
         
            -
                alias  
     | 
| 
      
 310 
     | 
    
         
            +
                alias sortable_attributes= update_sortable_attributes
         
     | 
| 
       291 
311 
     | 
    
         | 
| 
       292 
     | 
    
         
            -
                def  
     | 
| 
       293 
     | 
    
         
            -
                  http_delete "/indexes/#{@uid}/settings/attributes 
     | 
| 
      
 312 
     | 
    
         
            +
                def reset_sortable_attributes
         
     | 
| 
      
 313 
     | 
    
         
            +
                  http_delete "/indexes/#{@uid}/settings/sortable-attributes"
         
     | 
| 
       294 
314 
     | 
    
         
             
                end
         
     | 
| 
       295 
315 
     | 
    
         
             
              end
         
     | 
| 
       296 
316 
     | 
    
         
             
            end
         
     | 
    
        data/lib/meilisearch/version.rb
    CHANGED
    
    
    
        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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.16.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Meili
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2021- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-09-13 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: httparty
         
     | 
| 
         @@ -19,7 +19,7 @@ dependencies: 
     | 
|
| 
       19 
19 
     | 
    
         
             
                    version: 0.17.1
         
     | 
| 
       20 
20 
     | 
    
         
             
                - - "<"
         
     | 
| 
       21 
21 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       22 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 22 
     | 
    
         
            +
                    version: 0.20.0
         
     | 
| 
       23 
23 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       24 
24 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       25 
25 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -29,7 +29,7 @@ dependencies: 
     | 
|
| 
       29 
29 
     | 
    
         
             
                    version: 0.17.1
         
     | 
| 
       30 
30 
     | 
    
         
             
                - - "<"
         
     | 
| 
       31 
31 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       32 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 32 
     | 
    
         
            +
                    version: 0.20.0
         
     | 
| 
       33 
33 
     | 
    
         
             
            description: An easy-to-use ruby client for Meilisearch API. See https://github.com/meilisearch/MeiliSearch
         
     | 
| 
       34 
34 
     | 
    
         
             
            email: bonjour@meilisearch.com
         
     | 
| 
       35 
35 
     | 
    
         
             
            executables: []
         
     |