Skip to content
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

Analyze API to return 400 for wrong custom analyzer #121568

Merged
merged 7 commits into from
Feb 5, 2025

Conversation

mayya-sharipova
Copy link
Contributor

@mayya-sharipova mayya-sharipova commented Feb 3, 2025

If a custom analyzer provided in _analyze API
can not be built, return 400 instead of the current
500. This most probably means that the user's provided analyzer specifications are wrong.

Closes #121443

If a custom analyzer provided in _analyze API
can not be built, return 400 instead of the current
500. This most probably means that the user's provided
analyzer specificatons are wrong.

Closes elastic#121443
@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Feb 3, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine
Copy link
Collaborator

Hi @mayya-sharipova, I've created a changelog YAML for you.

Copy link
Contributor

@john-wagster john-wagster left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -65,6 +66,8 @@
*/
public class TransportAnalyzeAction extends TransportSingleShardAction<AnalyzeAction.Request, AnalyzeAction.Response> {

public static final NodeFeature WRONG_CUSTOM_ANALYZER_RETURN_400 = new NodeFeature("wrong_custom_analyzer_return_400");
Copy link
Contributor

Choose a reason for hiding this comment

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

more for curiosity does this need to be a nodefeature or can it be a test feature. it's unfortunate stuff like this has to be enumerated.

@@ -65,6 +66,8 @@
*/
public class TransportAnalyzeAction extends TransportSingleShardAction<AnalyzeAction.Request, AnalyzeAction.Response> {

public static final NodeFeature WRONG_CUSTOM_ANALYZER_RETURN_400 = new NodeFeature("wrong_custom_analyzer_return_400");
Copy link
Member

Choose a reason for hiding this comment

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

Could you simply make this a capability on the REST API side? That is much simpler and then you don't need all these feature things.

@mayya-sharipova
Copy link
Contributor Author

mayya-sharipova commented Feb 5, 2025

@john-wagster @benwtrent Thank you for the feedback. I've modified the PR to use capabilties instead of a node feature.

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

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

:shipit:

@benwtrent benwtrent added v9.0.0 auto-backport Automatically create backport pull requests when merged labels Feb 5, 2025
@mayya-sharipova mayya-sharipova added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Feb 5, 2025
@elasticsearchmachine elasticsearchmachine merged commit 5a56832 into elastic:main Feb 5, 2025
17 checks passed
@mayya-sharipova mayya-sharipova deleted the analyze-api-400 branch February 5, 2025 20:24
mayya-sharipova added a commit to mayya-sharipova/elasticsearch that referenced this pull request Feb 5, 2025
If a custom analyzer provided in _analyze API can not be built, return
400 instead of the current 500. This most probably means that the user's
provided analyzer specifications are wrong.

Closes elastic#121443
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
9.0
8.x

mayya-sharipova added a commit to mayya-sharipova/elasticsearch that referenced this pull request Feb 5, 2025
If a custom analyzer provided in _analyze API can not be built, return
400 instead of the current 500. This most probably means that the user's
provided analyzer specifications are wrong.

Closes elastic#121443
elasticsearchmachine pushed a commit that referenced this pull request Feb 5, 2025
If a custom analyzer provided in _analyze API can not be built, return
400 instead of the current 500. This most probably means that the user's
provided analyzer specifications are wrong.

Closes #121443
elasticsearchmachine pushed a commit that referenced this pull request Feb 5, 2025
If a custom analyzer provided in _analyze API can not be built, return
400 instead of the current 500. This most probably means that the user's
provided analyzer specifications are wrong.

Closes #121443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >bug :Search Relevance/Analysis How text is split into tokens Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v8.19.0 v9.0.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When calling the _analyze API, it should be a 4xx when dictionary files are missing
4 participants