Skip to content

Add swap indexes for v0.30.0 #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

bidoubiwa
Copy link
Contributor

@bidoubiwa bidoubiwa commented Nov 15, 2022

As per the specification

Enhancement

It is now possible to swap two indexes

Usage:

    client.swap_indexes([&SwapIndexes {
       indexes: (
            "index_a".to_string(),
             "index_b".to_string(),
       ),
    }])

Complete Example:

async fn test_swapping_two_indexes(client: Client) {
        let index_1 = client.index("test_swapping_two_indexes_1");
        let index_2 = client.index("test_swapping_two_indexes_2");

        let t0 = index_1
            .add_documents(
                &[Document {
                    id: "1".to_string(),
                }],
                None,
            )
            .await
            .unwrap();

        index_2
            .add_documents(
                &[Document {
                    id: "2".to_string(),
                }],
                None,
            )
            .await
            .unwrap();

        t0.wait_for_completion(&client, None, None).await.unwrap();

        let task = client
            .swap_indexes([&SwapIndexes {
                indexes: (
                    "test_swapping_two_indexes_1".to_string(),
                    "test_swapping_two_indexes_2".to_string(),
                ),
            }])
            .await
            .unwrap();
        task.wait_for_completion(&client, None, None).await.unwrap();

        let document = index_1.get_document("2").await.unwrap();

        assert_eq!(
            Document {
                id: "2".to_string()
            },
            document
        );

todo

  • create SwapIndexes struct
  • implement swap_indexes on client
  • add tests

@bidoubiwa bidoubiwa added the enhancement New feature or request label Nov 15, 2022
@bidoubiwa bidoubiwa requested a review from alallema November 16, 2022 13:09
@bidoubiwa bidoubiwa marked this pull request as ready for review November 16, 2022 13:09
Copy link
Contributor

@alallema alallema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just few question but well done 🔥 🔥 🔥

@bidoubiwa bidoubiwa force-pushed the bump-meilisearch-v0.30.0-add-swap-indexes-v0.30.0 branch from b140892 to bd9e602 Compare November 16, 2022 17:06
@bidoubiwa bidoubiwa requested a review from alallema November 16, 2022 17:07
Copy link
Contributor

@alallema alallema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎉 🍣

@bidoubiwa bidoubiwa merged commit 5d834cb into bump-meilisearch-v0.30.0-add-delete-tasks Nov 17, 2022
@bidoubiwa bidoubiwa deleted the bump-meilisearch-v0.30.0-add-swap-indexes-v0.30.0 branch November 17, 2022 12:53
bidoubiwa added a commit that referenced this pull request Nov 17, 2022
* Add delete tasks for v0.30.0

* Add swap indexes for v0.30.0 (#382)

* Add swap indexes for v0.30.0

* Implement swap indexes

* Add indexSwap detail

* Use tuples as type for the indexes field

* Add tests on index swap

* Create better documentation for indexes swap

* Fix clippy errors

* Fix missing bracket

* Fix swap doc test

* Make doc more clear
bidoubiwa added a commit that referenced this pull request Nov 17, 2022
* Update README.md

* Update README.tpl

* Add filters in tasksQuery

* Add new error codes

* Add builder methods and tests

* Fix clippy suggestions

* Update src/tasks.rs

Co-authored-by: Amélie <[email protected]>

* Implement default taskQuery structure

* Fix flacky tests

* Fix get_tasks test

* Refactor filtering of tasks

* Rename index_uids and task types

* Rename uid, status and types filters to plural

* Add new error codes

* Update error code to plural form

* Update code samples

* Update code-samples with new filter plural naming

* Rename filters to plural form

* Implement cancel_tasks

* Add taskCancelation task details

* Fix execution of get_tasks

* Add canceled by as a return from task

* Fix taskCancelation detail

* Fix typing error

* Chage type of canceled_by

* Make variable plural

* Rollback unrelated changes

* Change variable to plural form

* Add delete tasks for v0.30.0 (#381)

* Add delete tasks for v0.30.0

* Add swap indexes for v0.30.0 (#382)

* Add swap indexes for v0.30.0

* Implement swap indexes

* Add indexSwap detail

* Use tuples as type for the indexes field

* Add tests on index swap

* Create better documentation for indexes swap

* Fix clippy errors

* Fix missing bracket

* Fix swap doc test

* Make doc more clear

Co-authored-by: meili-bot <[email protected]>
Co-authored-by: Amélie <[email protected]>
bors bot added a commit that referenced this pull request Nov 28, 2022
399: Update version for the next release (v0.21.0) r=bidoubiwa a=bidoubiwa

This version makes this package compatible with Meilisearch v0.30.0 🎉
Check out the changelog of [Meilisearch v0.30.0](https://github.com/meilisearch/meilisearch/releases/tag/v0.30.0) for more information on the changes.

## 🚀 Enhancements

- New `pagination` strategy with the search parameters`page` and `hitsPerPage` #374
- New bulder methods on `get_tasks`: `with_uids`, `with_before_enqueued_at`, ... see #375
- New `client.cancel_tasks` method that lets you cancel `enqueued` and `processing` tasks #377 
- New `client.delete_tasks` method that lets you delete tasks #381 
- New `client.swap_indexes` method that lets you swap two indexes #382

## ⚠️ Breaking change

- builder functions on `TasksQuery` name changes: #375
   - `with_status` -> `with_statuses`
   - `with_index_uid` -> `with_index_uids`
   - `with_type` -> `with_types`
- Task detail `receivedDocumentIds` renamed to `providedIds` #393
- Error field in `Task` is now always present and has a `None` value when there are no errors #390
- Add and rename some error codes: #384 

Co-authored-by: Charlotte Vermandel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants