diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 8c05c952..7acec509 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -515,3 +515,12 @@ distinct_attribute_guide_distinct_parameter_1: |- client.index('products').search('white shirt', { distinct: 'sku' }) +export_post_1: |- + client.export({ + url: "TARGET_INSTANCE_URL", + indexes: { + "*": { + "overrideSettings": true + } + } + }) diff --git a/lib/meilisearch/client.rb b/lib/meilisearch/client.rb index 72da699b..1eedaeb2 100644 --- a/lib/meilisearch/client.rb +++ b/lib/meilisearch/client.rb @@ -470,6 +470,24 @@ def batch(batch_uid) http_get "/batches/#{batch_uid}" end + ### EXPORT + + # Migrate between instances with the /export route + # + # @see https://www.meilisearch.com/docs/reference/api/export Meilisearch API reference + # @param export_options [Hash{Symbol => Object}] the export options of which the required are + # - +:url+ +String+ the target instance’s URL address + # - +:api_key+ +String+ an API key with full admin access to the target instance + # - +:payload_size+ +String+ a string specifying the payload size in a human-readable format + # - +:indexes+ +Hash+ A set of patterns matching the indexes you want to export. Defaults to all indexes in the origin instance + # @return [Models::Task] the async task that is creating the export + def export(export_options) + body = Utils.transform_attributes(export_options) + + response = http_post '/export', body + Models::Task.new(response, task_endpoint) + end + ### EXPERIMENTAL FEATURES def experimental_features diff --git a/spec/meilisearch/client/exports_spec.rb b/spec/meilisearch/client/exports_spec.rb new file mode 100644 index 00000000..6c978a29 --- /dev/null +++ b/spec/meilisearch/client/exports_spec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +RSpec.describe 'Meilisearch::Client - Export' do + it 'creates a new export' do + task = client.export({ url: 'localhost:7701', indexes: { '*': { overrideSettings: true } } }) + + expect(task.type).to eq('export') + end +end