Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add typo tolerance settings #443

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

Merged
merged 10 commits into from
Apr 28, 2022
Merged

Conversation

alallema
Copy link
Contributor

@alallema alallema commented Apr 20, 2022

This PR introduces the new setting: typoTolerance

new methods:
index.get_typo_tolerance()
index.update_typo_tolerance(params)
index.reset_typo_tolerance()

Copy link
Contributor

@bidoubiwa bidoubiwa left a comment

Choose a reason for hiding this comment

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

I think a tests is missing in SettingsTest.py

@@ -289,7 +289,7 @@ def add_documents(
self,
documents: List[Dict[str, Any]],
primary_key: Optional[str] = None,
) -> Dict[str, int]:
) -> Dict[str, Any]:
Copy link
Contributor

@bidoubiwa bidoubiwa Apr 25, 2022

Choose a reason for hiding this comment

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

There is no type definition in python ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean? Something like:
Dict[str, str|int]:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It receives a Task so it could be int, str, or even Dict.

Copy link
Contributor

Choose a reason for hiding this comment

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

Something like

Type: {

  uid: Int, 
  indexUid: string
}

etc

Copy link
Collaborator

@sanders41 sanders41 Apr 25, 2022

Choose a reason for hiding this comment

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

There is a TypedDict, but it is first available in Python 3.8. You can do it all the way back to Python 3.6 by using Pydantic classes instead of dictionaries, but that would be a big change.

Pydantic is how I do it so if you do decide to go this direction feel free to grab my models and use them here https://github.com/sanders41/meilisearch-python-async/tree/main/meilisearch_python_async/models

Copy link
Contributor Author

@alallema alallema Apr 25, 2022

Choose a reason for hiding this comment

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

@bidoubiwa, yes we could create a task class to use on the prototype on all these functions you can create an issue about it! If that what you meant
And yes, if we do, of course, we will be inspired by your models @sanders41 thank you very much for the reference.

Copy link
Member

Choose a reason for hiding this comment

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

This could represent a breaking change for the user in any form?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@brunoocasali it depends on how you look at it. Really Dict[str, int] has been wrong since tasks were introduced and I am thinking @alallema is first to notice and made the correction here. So really it was breaking in a previous release and a bug fix here.

The reason this was easy to miss is a dictionary is returned, but mypy has no way to know what the dictionary will be with the current implementation. Since all it knows you you said you are returning a dictionary and one is being returned it assumes you have the rest correct. The point @bidoubiwa brings up would prevent this from happening because at that point mypy would know exactly what to expect in the return values.

Copy link
Contributor

Choose a reason for hiding this comment

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

I made an issue #449

@alallema alallema requested review from sanders41 and bidoubiwa April 25, 2022 15:04
@@ -289,7 +289,7 @@ def add_documents(
self,
documents: List[Dict[str, Any]],
primary_key: Optional[str] = None,
) -> Dict[str, int]:
) -> Dict[str, Any]:
Copy link
Member

Choose a reason for hiding this comment

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

This could represent a breaking change for the user in any form?

"""Tests updating typo_tolerance."""
index = empty_index()
response = index.update_typo_tolerance(NEW_TYPO_TOLERANCE)
assert isinstance(response, dict)
Copy link
Member

Choose a reason for hiding this comment

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

Can you apply some testing practices like the ones we discuss here? meilisearch/integration-guides#153

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you mean to just add some spaces between the different steps or also the naming? Also, I know I had to apply these testing practices but these new tests are in the same format that all the others. I had some trouble doing something different in just one place in a repository even if it's not really good practice.

Copy link
Member

Choose a reason for hiding this comment

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

I see your point of view, and I totally agree with it in most cases, but in this particular case, you could do that without creating a mess with different styles.

@@ -1168,6 +1152,67 @@ def reset_sortable_attributes(self) -> Dict[str, int]:
self.__settings_url_for(self.config.paths.sortable_attributes),
)

# TYPO TOLERANCE SUB-ROUTES
Copy link
Member

Choose a reason for hiding this comment

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

Does it seem a responsibility for a settings.py file, don't you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@brunoocasali Yes, I thought the same thing about adding another settings in the index.py file but isn't it better to do it during the rest of maintenance in a separate PR? Or do you prefer I modify it in this PR?

Copy link
Member

Choose a reason for hiding this comment

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

I don't see a problem if you track that change, like, add the new configurations in a new file, and then create an index to address the following changes in the new place.

@alallema alallema requested a review from brunoocasali April 26, 2022 12:29
Copy link
Contributor

@bidoubiwa bidoubiwa left a comment

Choose a reason for hiding this comment

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

LGTM 🔥

@alallema alallema merged commit 5b28d58 into bump-meilisearch-v0.27.0 Apr 28, 2022
@alallema alallema deleted the typo-tolerance branch April 28, 2022 14:41
bors bot added a commit that referenced this pull request May 9, 2022
439: Changes related to the next Meilisearch release (v0.27.0) r=curquiza a=meili-bot

Related to this issue: meilisearch/integration-guides#190

This PR:
- gathers the changes related to the next Meilisearch release (v0.27.0) so that this package is ready when the official release is out.
- should pass the tests against the [latest pre-release of Meilisearch](https://github.com/meilisearch/meilisearch/releases).
- might eventually contain test failures until the Meilisearch v0.27.0 is out.

⚠️ This PR should NOT be merged until the next release of Meilisearch (v0.27.0) is out.

_This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/master/guides/pre-release-week.md) purpose._

Done:
- #440 
- #443 
- #444 
- #445
- #450 


Co-authored-by: meili-bot <[email protected]>
Co-authored-by: Bruno Casali <[email protected]>
Co-authored-by: alallema <[email protected]>
Co-authored-by: Amélie <[email protected]>
bors bot added a commit that referenced this pull request May 9, 2022
456: Update version for the next release (v0.18.3) r=curquiza a=alallema

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

## 🚀 Enhancements

- Add new methods for the new typo tolerance settings #443 `@alallema`
`index.get_typo_tolerance()`
`index.update_typo_tolerance(params)`
`index.reset_typo_tolerance()`
- Ensure nested field support #444 `@alallema`
- Add new search parameters highlightPreTag, highlightPostTag and cropMarker #445 `@alallema`


Co-authored-by: alallema <[email protected]>
@sanders41 sanders41 mentioned this pull request Feb 5, 2023
3 tasks
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.

4 participants