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

Remove synonyms feature flag and related classes #97962

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/97962.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 97962
summary: Introduce Synonyms Management API used for synonym and synonym_graph filters
area: Search
type: enhancement
issues:
- 38523
1 change: 0 additions & 1 deletion modules/analysis-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ restResources {
testClusters.configureEach {
module ':modules:reindex'
module ':modules:mapper-extras'
requiresFeature 'es.synonyms_api_feature_flag_enabled', Version.fromString("8.9.0")
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.elasticsearch.index.analysis.CustomAnalyzer;
import org.elasticsearch.index.analysis.TokenFilterFactory;
import org.elasticsearch.index.analysis.TokenizerFactory;
import org.elasticsearch.synonyms.SynonymsAPI;
import org.elasticsearch.synonyms.SynonymsManagementAPIService;

import java.io.Reader;
Expand Down Expand Up @@ -161,7 +160,7 @@ protected ReaderWithOrigin getRulesFromSettings(Environment env, IndexCreationCo
sb.append(line).append(System.lineSeparator());
}
return new ReaderWithOrigin(new StringReader(sb.toString()), "'" + name() + "' analyzer settings");
} else if ((settings.get("synonyms_set") != null) && SynonymsAPI.isEnabled()) {
} else if (settings.get("synonyms_set") != null) {
if (analysisMode != AnalysisMode.SEARCH_TIME) {
throw new IllegalArgumentException(
"Can't apply [synonyms_set]! " + "Loading synonyms from index is supported only for search time synonyms!"
Expand All @@ -186,8 +185,7 @@ protected ReaderWithOrigin getRulesFromSettings(Environment env, IndexCreationCo
String synonyms_path = settings.get("synonyms_path", null);
return new ReaderWithOrigin(Analysis.getReaderFromFile(env, synonyms_path, "synonyms_path"), synonyms_path);
} else {
String err = SynonymsAPI.isEnabled() ? "`synonyms_set`," : "";
throw new IllegalArgumentException("synonym requires either `synonyms`," + err + " or `synonyms_path` to be configured");
throw new IllegalArgumentException("synonym requires either `synonyms`, `synonyms_set` or `synonyms_path` to be configured");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class SmokeTestMultiNodeClientYamlTestSuiteIT extends ESClientYamlSuiteTe
.node(0, n -> n.setting("node.roles", "[master,data,ml,remote_cluster_client,transform]"))
.feature(FeatureFlag.TIME_SERIES_MODE)
.feature(FeatureFlag.DATA_STREAM_LIFECYCLE_ENABLED)
.feature(FeatureFlag.SYNONYMS_ENABLED)
.build();

public SmokeTestMultiNodeClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
Expand Down
4 changes: 0 additions & 4 deletions rest-api-spec/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ dependencies {
clusterModules project(':modules:analysis-common')
}

testClusters.configureEach {
requiresFeature 'es.synonyms_api_feature_flag_enabled', Version.fromString("8.9.0")
}

tasks.named("yamlRestTestV7CompatTransform").configure { task ->

task.skipTestsByFilePattern("**/cat*/*.yml", "Cat API are meant to be consumed by humans, so will not be supported by Compatible REST API")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"description": "Deletes a synonym rule in a synonym set"
},
"stability": "experimental",
"visibility": "feature_flag",
"feature_flag": "es.synonyms_api_feature_flag_enabled",
"visibility": "public",
"headers": {
"accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"description": "Retrieves a synonym rule from a synonym set"
},
"stability": "experimental",
"visibility": "feature_flag",
"feature_flag": "es.synonyms_api_feature_flag_enabled",
"visibility": "public",
"headers": {
"accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"description": "Creates or updates a synonym rule in a synonym set"
},
"stability": "experimental",
"visibility": "feature_flag",
"feature_flag": "es.synonyms_api_feature_flag_enabled",
"visibility": "public",
"headers": {
"accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"description": "Deletes a synonym set"
},
"stability": "experimental",
"visibility": "feature_flag",
"feature_flag": "es.synonyms_api_feature_flag_enabled",
"visibility": "public",
"headers": {
"accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"description": "Retrieves a synonym set"
},
"stability": "experimental",
"visibility": "feature_flag",
"feature_flag": "es.synonyms_api_feature_flag_enabled",
"visibility": "public",
"headers": {
"accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"description": "Creates or updates a synonyms set"
},
"stability": "experimental",
"visibility": "feature_flag",
"feature_flag": "es.synonyms_api_feature_flag_enabled",
"visibility": "public",
"headers": {
"accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"description": "Retrieves a summary of all defined synonym sets"
},
"stability": "experimental",
"visibility": "feature_flag",
"feature_flag": "es.synonyms_api_feature_flag_enabled",
"visibility": "public",
"headers": {
"accept": [
"application/json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class ClientYamlTestSuiteIT extends ESClientYamlSuiteTestCase {
.module("analysis-common")
.feature(FeatureFlag.TIME_SERIES_MODE)
.feature(FeatureFlag.DATA_STREAM_LIFECYCLE_ENABLED)
.feature(FeatureFlag.SYNONYMS_ENABLED)
.build();

public ClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
Expand Down
33 changes: 14 additions & 19 deletions server/src/main/java/org/elasticsearch/action/ActionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@
import org.elasticsearch.rest.action.synonyms.RestGetSynonymsSetsAction;
import org.elasticsearch.rest.action.synonyms.RestPutSynonymRuleAction;
import org.elasticsearch.rest.action.synonyms.RestPutSynonymsAction;
import org.elasticsearch.synonyms.SynonymsAPI;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.tracing.Tracer;
Expand Down Expand Up @@ -799,15 +798,13 @@ public <Request extends ActionRequest, Response extends ActionResponse> void reg
actions.register(FetchHealthInfoCacheAction.INSTANCE, FetchHealthInfoCacheAction.TransportAction.class);

// Synonyms
if (SynonymsAPI.isEnabled()) {
actions.register(PutSynonymsAction.INSTANCE, TransportPutSynonymsAction.class);
actions.register(GetSynonymsAction.INSTANCE, TransportGetSynonymsAction.class);
actions.register(DeleteSynonymsAction.INSTANCE, TransportDeleteSynonymsAction.class);
actions.register(GetSynonymsSetsAction.INSTANCE, TransportGetSynonymsSetsAction.class);
actions.register(PutSynonymRuleAction.INSTANCE, TransportPutSynonymRuleAction.class);
actions.register(GetSynonymRuleAction.INSTANCE, TransportGetSynonymRuleAction.class);
actions.register(DeleteSynonymRuleAction.INSTANCE, TransportDeleteSynonymRuleAction.class);
}
actions.register(PutSynonymsAction.INSTANCE, TransportPutSynonymsAction.class);
actions.register(GetSynonymsAction.INSTANCE, TransportGetSynonymsAction.class);
actions.register(DeleteSynonymsAction.INSTANCE, TransportDeleteSynonymsAction.class);
actions.register(GetSynonymsSetsAction.INSTANCE, TransportGetSynonymsSetsAction.class);
actions.register(PutSynonymRuleAction.INSTANCE, TransportPutSynonymRuleAction.class);
actions.register(GetSynonymRuleAction.INSTANCE, TransportGetSynonymRuleAction.class);
actions.register(DeleteSynonymRuleAction.INSTANCE, TransportDeleteSynonymRuleAction.class);

return unmodifiableMap(actions.getRegistry());
}
Expand Down Expand Up @@ -1019,15 +1016,13 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster) {
registerHandler.accept(new RestCatAction(catActions));

// Synonyms
if (SynonymsAPI.isEnabled()) {
registerHandler.accept(new RestPutSynonymsAction());
registerHandler.accept(new RestGetSynonymsAction());
registerHandler.accept(new RestDeleteSynonymsAction());
registerHandler.accept(new RestGetSynonymsSetsAction());
registerHandler.accept(new RestPutSynonymRuleAction());
registerHandler.accept(new RestGetSynonymRuleAction());
registerHandler.accept(new RestDeleteSynonymRuleAction());
}
registerHandler.accept(new RestPutSynonymsAction());
registerHandler.accept(new RestGetSynonymsAction());
registerHandler.accept(new RestDeleteSynonymsAction());
registerHandler.accept(new RestGetSynonymsSetsAction());
registerHandler.accept(new RestPutSynonymRuleAction());
registerHandler.accept(new RestGetSynonymRuleAction());
registerHandler.accept(new RestDeleteSynonymRuleAction());
}

/**
Expand Down
17 changes: 5 additions & 12 deletions server/src/main/java/org/elasticsearch/indices/SystemIndices.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.elasticsearch.index.Index;
import org.elasticsearch.plugins.SystemIndexPlugin;
import org.elasticsearch.snapshots.SnapshotsService;
import org.elasticsearch.synonyms.SynonymsAPI;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -54,6 +53,7 @@
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static org.elasticsearch.core.Strings.format;
import static org.elasticsearch.synonyms.SynonymsManagementAPIService.SYNONYMS_DESCRIPTOR;
Expand Down Expand Up @@ -118,17 +118,10 @@ public class SystemIndices {
/**
* This is the source for non-plugin system features.
*/
private static final Map<String, Feature> SERVER_SYSTEM_FEATURE_DESCRIPTORS;

static {
Collection<Feature> indicesFeatures = new ArrayList<>();
indicesFeatures.add(new Feature(TASKS_FEATURE_NAME, "Manages task results", List.of(TASKS_DESCRIPTOR)));
if (SynonymsAPI.isEnabled()) {
indicesFeatures.add(new Feature(SYNONYMS_FEATURE_NAME, "Manages synonyms", List.of(SYNONYMS_DESCRIPTOR)));
}
SERVER_SYSTEM_FEATURE_DESCRIPTORS = indicesFeatures.stream()
.collect(Collectors.toUnmodifiableMap(Feature::getName, Function.identity()));
}
private static final Map<String, Feature> SERVER_SYSTEM_FEATURE_DESCRIPTORS = Stream.of(
new Feature(TASKS_FEATURE_NAME, "Manages task results", List.of(TASKS_DESCRIPTOR)),
new Feature(SYNONYMS_FEATURE_NAME, "Manages synonyms", List.of(SYNONYMS_DESCRIPTOR))
).collect(Collectors.toUnmodifiableMap(Feature::getName, Function.identity()));

/**
* The node's full list of system features is stored here. The map is keyed
Expand Down
19 changes: 0 additions & 19 deletions server/src/main/java/org/elasticsearch/synonyms/SynonymsAPI.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package org.elasticsearch.indices;

import org.elasticsearch.synonyms.SynonymsAPI;
import org.elasticsearch.test.ESTestCase;

import java.util.Collections;
Expand Down Expand Up @@ -108,7 +107,7 @@ public void testBuiltInSystemIndices() {
assertTrue(systemIndices.isSystemIndex(".tasks"));
assertTrue(systemIndices.isSystemIndex(".tasks1"));
assertTrue(systemIndices.isSystemIndex(".tasks-old"));
assertEquals(SynonymsAPI.isEnabled(), systemIndices.isSystemIndex(".synonyms"));
assertTrue(systemIndices.isSystemIndex(".synonyms"));
}

public void testPluginCannotOverrideBuiltInSystemIndex() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
public enum FeatureFlag {
TIME_SERIES_MODE("es.index_mode_feature_flag_registered=true", Version.fromString("8.0.0"), null),
NEW_RCS_MODE("es.untrusted_remote_cluster_feature_flag_registered=true", Version.fromString("8.5.0"), null),
DATA_STREAM_LIFECYCLE_ENABLED("es.dlm_feature_flag_enabled=true", Version.fromString("8.8.0"), null),
SYNONYMS_ENABLED("es.synonyms_api_feature_flag_enabled=true", Version.fromString("8.9.0"), null);
DATA_STREAM_LIFECYCLE_ENABLED("es.dlm_feature_flag_enabled=true", Version.fromString("8.8.0"), null);

public final String systemProperty;
public final Version from;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.elasticsearch.action.ingest.SimulatePipelineAction;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.util.Maps;
import org.elasticsearch.synonyms.SynonymsAPI;
import org.elasticsearch.transport.RemoteClusterService;
import org.elasticsearch.transport.TcpTransport;
import org.elasticsearch.transport.TransportRequest;
Expand Down Expand Up @@ -353,7 +352,7 @@ public class ClusterPrivilegeResolver {
MANAGE_LOGSTASH_PIPELINES,
CANCEL_TASK,
MANAGE_SEARCH_APPLICATION,
SynonymsAPI.isEnabled() ? MANAGE_SEARCH_SYNONYMS : null,
MANAGE_SEARCH_SYNONYMS,
MANAGE_BEHAVIORAL_ANALYTICS,
POST_BEHAVIORAL_ANALYTICS_EVENT,
TcpTransport.isUntrustedRemoteClusterEnabled() ? CROSS_CLUSTER_SEARCH : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class CoreWithSecurityClientYamlTestSuiteIT extends ESClientYamlSuiteTest
.user(USER, PASS)
.feature(FeatureFlag.TIME_SERIES_MODE)
.feature(FeatureFlag.DATA_STREAM_LIFECYCLE_ENABLED)
.feature(FeatureFlag.SYNONYMS_ENABLED)
.build();

public CoreWithSecurityClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
Expand Down