-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Analyze API to return 400 for wrong custom analyzer #121568
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
elasticsearchmachine
merged 7 commits into
elastic:main
from
mayya-sharipova:analyze-api-400
Feb 5, 2025
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cc2107d
Analyze API to return 400 for wrong custom analyzer
mayya-sharipova 5544e7c
Update docs/changelog/121568.yaml
mayya-sharipova 85063e1
[CI] Auto commit changes from spotless
33620d0
Address feedback: make capabilities intead of feature
mayya-sharipova 221ea48
Merge remote-tracking branch 'upstream/main' into analyze-api-400
mayya-sharipova 92a8cfa
[CI] Auto commit changes from spotless
92a88c8
Merge branch 'main' into analyze-api-400
mayya-sharipova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| pr: 121568 | ||
| summary: Analyze API to return 400 for wrong custom analyzer | ||
| area: Analysis | ||
| type: bug | ||
| issues: | ||
| - 121443 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
server/src/main/java/org/elasticsearch/action/admin/ActionFeatures.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.action.admin; | ||
|
|
||
| import org.elasticsearch.features.FeatureSpecification; | ||
| import org.elasticsearch.features.NodeFeature; | ||
|
|
||
| import java.util.Set; | ||
|
|
||
| import static org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction.WRONG_CUSTOM_ANALYZER_RETURN_400; | ||
|
|
||
| public class ActionFeatures implements FeatureSpecification { | ||
|
|
||
| @Override | ||
| public Set<NodeFeature> getFeatures() { | ||
| return Set.of(); | ||
| } | ||
|
|
||
| @Override | ||
| public Set<NodeFeature> getTestFeatures() { | ||
| return Set.of(WRONG_CUSTOM_ANALYZER_RETURN_400); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| import org.elasticsearch.common.io.stream.Writeable; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.core.IOUtils; | ||
| import org.elasticsearch.features.NodeFeature; | ||
| import org.elasticsearch.index.IndexService; | ||
| import org.elasticsearch.index.IndexService.IndexCreationContext; | ||
| import org.elasticsearch.index.IndexSettings; | ||
|
|
@@ -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"); | ||
|
||
|
|
||
| private final Settings settings; | ||
| private final IndicesService indicesService; | ||
|
|
||
|
|
@@ -144,6 +147,8 @@ public static AnalyzeAction.Response analyze( | |
| if (analyzer != null) { | ||
| return analyze(request, analyzer, maxTokenCount); | ||
| } | ||
| } catch (IllegalStateException e) { | ||
| throw new IllegalArgumentException("Can not build a custom analyzer", e); | ||
| } | ||
|
|
||
| // Otherwise we use a built-in analyzer, which should not be closed | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.