meilisearch-rust icon indicating copy to clipboard operation
meilisearch-rust copied to clipboard

Add support for typo tolerance customization

Open vishalsodani opened this issue 3 years ago • 4 comments

Pull Request

Related issue

Fixes #260

What does this PR do?

  • ...

PR checklist

Please check if your PR fulfills the following requirements:

  • [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • [x] Have you read the contributing guidelines?
  • [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

vishalsodani avatar Oct 10 '22 16:10 vishalsodani

I know it was not part of the PR description, but could you add (or update) the following code-samples based on this example:

  • get_typo_tolerance_1
  • update_typo_tolerance_1
  • reset_typo_tolerance_1
  • typo_tolerance_guide_1
  • typo_tolerance_guide_2
  • typo_tolerance_guide_3
  • typo_tolerance_guide_4
  • settings_guide_typo_tolerance_1
  • getting_started_typo_tolerance
  • update_settings_1

bidoubiwa avatar Oct 12 '22 10:10 bidoubiwa

I know it was not part of the PR description, but could you add (or update) the following code-samples based on this example:

* get_typo_tolerance_1

* update_typo_tolerance_1

* reset_typo_tolerance_1

* typo_tolerance_guide_1

* typo_tolerance_guide_2

* typo_tolerance_guide_3

* typo_tolerance_guide_4

* settings_guide_typo_tolerance_1

* getting_started_typo_tolerance

* update_settings_1

ok. I will add these.

vishalsodani avatar Oct 13 '22 04:10 vishalsodani

Hey @vishalsodani thanks for this contribution :)

Could you look at the specification? I think the parameters are optional

Can you please review? I have made the parameters optional. Is the implementation ok?

vishalsodani avatar Oct 13 '22 09:10 vishalsodani

one_type and two_typos are u8 and not i64. See here

bidoubiwa avatar Oct 13 '22 11:10 bidoubiwa

Hi,

I feel there is an issue with this API design. If I tun this test, the test fails

`

     #[meilisearch_test]

     async fn test_set_typo_tolerance(client: Client, index: Index) {

    let typo_tolerance = TypoToleranceSettings {
        enabled: None,
        disable_on_attributes: Some(vec![]),
        disable_on_words: Some(vec![]),
        min_word_size_for_typos: Some(MinWordSizeForTypos {
            one_typo: Some(6),
            two_typos: Some(9),
        }),
    };
    let task_info = index.set_typo_tolerance(&typo_tolerance).await.unwrap();
    client.wait_for_task(task_info, None, None).await.unwrap();

    let res = index.get_typo_tolerance().await.unwrap();

    assert_eq!(typo_tolerance, res);
}

    left: `TypoToleranceSettings { enabled: None, disable_on_attributes: Some([]), disable_on_words: Some([]), min_word_size_for_typos: Some(MinWordSizeForTypos { one_typo: Some(6), two_typos: Some(9) }) }`,

   right: `TypoToleranceSettings { enabled: Some(true), disable_on_attributes: Some([]), disable_on_words: Some([]), min_word_size_for_typos: Some(MinWordSizeForTypos { one_typo: Some(6), two_typos: Some(9) }) }`', src/settings.rs:1609:9

We are setting enabled as None which should not be allowed. Am I correct?

vishalsodani avatar Oct 16 '22 07:10 vishalsodani

I know it was not part of the PR description, but could you add (or update) the following code-samples based on this example:

* get_typo_tolerance_1

* update_typo_tolerance_1

* reset_typo_tolerance_1

* typo_tolerance_guide_1

* typo_tolerance_guide_2

* typo_tolerance_guide_3

* typo_tolerance_guide_4

* settings_guide_typo_tolerance_1

* getting_started_typo_tolerance

* update_settings_1

Added.

vishalsodani avatar Oct 16 '22 11:10 vishalsodani

Hey @vishalsodani thanks for this contribution :)

Could you look at the specification? I think the parameters are optional

I have redesigned the API to use a builder pattern. So, a user is able to create a default object and can then set various attributes.

vishalsodani avatar Oct 16 '22 11:10 vishalsodani

@bidoubiwa Hi, I am done with all the changes. Please review. Thanks!

vishalsodani avatar Oct 17 '22 14:10 vishalsodani

  • default_one_typo_size

ok. Should I also revert the builder pattern? It does not seem that useful now.

vishalsodani avatar Oct 18 '22 14:10 vishalsodani

Hey @vishalsodani

Actually, you are right and just raised a bug in Meilisearch haha! See this spec

Great!

vishalsodani avatar Oct 18 '22 14:10 vishalsodani

Should I also revert the builder pattern? It does not seem that useful now.

Yes probably it is best to keep consistency with the other nested settings like pagination that are not using the builder pattern.

bidoubiwa avatar Oct 18 '22 14:10 bidoubiwa

@bidoubiwa

Can you remove: Done

vishalsodani avatar Oct 18 '22 15:10 vishalsodani

This message is sent automatically

Thanks again for contributing to Meilisearch :heart: If you are participating in Hacktoberfest, and you would like to receive some gift from Meilisearch too, please complete this form.

bidoubiwa avatar Oct 26 '22 16:10 bidoubiwa

Hey @vishalsodani I'm a bit underwater right now. I gave you the hacktoberfest-accepted label in order to validate your PR for DO.

bidoubiwa avatar Oct 26 '22 16:10 bidoubiwa

What's the state of this PR? I can also help to improve it if there is something missing?

We need this.

omid avatar May 11 '23 08:05 omid

@irevoire, the original author hasn't had any activity on GitHub since then. Seems like somebody else needs to take control.

omid avatar May 15 '23 15:05 omid

It's been merged via the following PR: https://github.com/meilisearch/meilisearch-rust/pull/480 @bidoubiwa let's close this also 🙏🏼

omid avatar Jun 12 '23 10:06 omid

Absolutely :)

bidoubiwa avatar Jun 13 '23 09:06 bidoubiwa