File tree Expand file tree Collapse file tree 5 files changed +60
-0
lines changed
modules/analysis-common/src/yamlRestTest/resources/rest-api-spec/test/indices.analyze
org/elasticsearch/action/admin
resources/META-INF/services Expand file tree Collapse file tree 5 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 5959 - match : { detail.tokenizer.tokens.0.token: ABc }
6060 - match : { detail.tokenfilters.0.name: lowercase }
6161 - match : { detail.tokenfilters.0.tokens.0.token: abc }
62+
63+ ---
64+ " Custom analyzer is not buildable " :
65+ - requires :
66+ cluster_features : [ "wrong_custom_analyzer_return_400" ]
67+ reason : " Returning 400 for wrong custom analyzer was added in this version"
68+
69+ - do :
70+ catch : bad_request
71+ indices.analyze :
72+ body :
73+ text : the foxes jumping quickly
74+ tokenizer :
75+ standard
76+ filter :
77+ type : hunspell
78+ locale : en_US
79+
80+ - match : { status: 400 }
81+ - match : { error.type: illegal_argument_exception }
82+ - match : { error.reason: "Can not build a custom analyzer" }
Original file line number Diff line number Diff line change 426426 provides org .elasticsearch .features .FeatureSpecification
427427 with
428428 org .elasticsearch .action .bulk .BulkFeatures ,
429+ org .elasticsearch .action .admin .ActionFeatures ,
429430 org .elasticsearch .features .FeatureInfrastructureFeatures ,
430431 org .elasticsearch .rest .action .admin .cluster .ClusterRerouteFeatures ,
431432 org .elasticsearch .index .mapper .MapperFeatures ,
476477 exports org .elasticsearch .monitor .metrics ;
477478 exports org .elasticsearch .plugins .internal .rewriter to org .elasticsearch .inference ;
478479 exports org .elasticsearch .lucene .util .automaton ;
480+ exports org .elasticsearch .action .admin ;
479481}
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+ * or more contributor license agreements. Licensed under the "Elastic License
4+ * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+ * Public License v 1"; you may not use this file except in compliance with, at
6+ * your election, the "Elastic License 2.0", the "GNU Affero General Public
7+ * License v3.0 only", or the "Server Side Public License, v 1".
8+ */
9+
10+ package org .elasticsearch .action .admin ;
11+
12+ import org .elasticsearch .features .FeatureSpecification ;
13+ import org .elasticsearch .features .NodeFeature ;
14+
15+ import java .util .Set ;
16+
17+ import static org .elasticsearch .action .admin .indices .analyze .TransportAnalyzeAction .WRONG_CUSTOM_ANALYZER_RETURN_400 ;
18+
19+ public class ActionFeatures implements FeatureSpecification {
20+
21+ @ Override
22+ public Set <NodeFeature > getFeatures () {
23+ return Set .of ();
24+ }
25+
26+
27+ @ Override
28+ public Set <NodeFeature > getTestFeatures () {
29+ return Set .of (WRONG_CUSTOM_ANALYZER_RETURN_400 );
30+ }
31+ }
Original file line number Diff line number Diff line change 2929import org .elasticsearch .common .io .stream .Writeable ;
3030import org .elasticsearch .common .settings .Settings ;
3131import org .elasticsearch .core .IOUtils ;
32+ import org .elasticsearch .features .NodeFeature ;
3233import org .elasticsearch .index .IndexService ;
3334import org .elasticsearch .index .IndexService .IndexCreationContext ;
3435import org .elasticsearch .index .IndexSettings ;
6566 */
6667public class TransportAnalyzeAction extends TransportSingleShardAction <AnalyzeAction .Request , AnalyzeAction .Response > {
6768
69+ public static final NodeFeature WRONG_CUSTOM_ANALYZER_RETURN_400 = new NodeFeature ("wrong_custom_analyzer_return_400" );
70+
6871 private final Settings settings ;
6972 private final IndicesService indicesService ;
7073
@@ -144,6 +147,8 @@ public static AnalyzeAction.Response analyze(
144147 if (analyzer != null ) {
145148 return analyze (request , analyzer , maxTokenCount );
146149 }
150+ } catch (IllegalStateException e ) {
151+ throw new IllegalArgumentException ("Can not build a custom analyzer" , e );
147152 }
148153
149154 // Otherwise we use a built-in analyzer, which should not be closed
Original file line number Diff line number Diff line change 88#
99
1010org.elasticsearch.action.bulk.BulkFeatures
11+ org.elasticsearch.action.admin.ActionFeatures
1112org.elasticsearch.features.FeatureInfrastructureFeatures
1213org.elasticsearch.rest.action.admin.cluster.ClusterRerouteFeatures
1314org.elasticsearch.index.IndexFeatures
You can’t perform that action at this time.
0 commit comments