-
Notifications
You must be signed in to change notification settings - Fork 90
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
Conversation
There was a problem hiding this 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]: |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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]:
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@@ -289,7 +289,7 @@ def add_documents( | |||
self, | |||
documents: List[Dict[str, Any]], | |||
primary_key: Optional[str] = None, | |||
) -> Dict[str, int]: | |||
) -> Dict[str, Any]: |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🔥
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]>
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]>
This PR introduces the new setting: typoTolerance
new methods:
index.get_typo_tolerance()
index.update_typo_tolerance(params)
index.reset_typo_tolerance()