use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class CreateAnalyzerAnalyzerTest method testCreateAnalyzerWithCustomTokenizer.
@Test
public void testCreateAnalyzerWithCustomTokenizer() throws Exception {
ClusterUpdateSettingsRequest request = analyze("CREATE ANALYZER a2 (" + " TOKENIZER tok2 with (" + " type='ngram'," + " \"min_ngram\"=2," + " \"token_chars\"=['letter', 'digits']" + " )" + ")");
assertThat(extractAnalyzerSettings("a2", request.persistentSettings()), allOf(hasEntry("index.analysis.analyzer.a2.tokenizer", "a2_tok2"), hasEntry("index.analysis.analyzer.a2.type", "custom")));
var tokenizerSettings = FulltextAnalyzerResolver.decodeSettings(request.persistentSettings().get(TOKENIZER.buildSettingName("a2_tok2")));
assertThat(tokenizerSettings, allOf(hasEntry("index.analysis.tokenizer.a2_tok2.min_ngram", "2"), hasEntry("index.analysis.tokenizer.a2_tok2.type", "ngram"), hasEntry("index.analysis.tokenizer.a2_tok2.token_chars", "[letter, digits]")));
}
use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class DropAnalyzerTest method testDropAnalyzerWithCustomTokenFilter.
@Test
public void testDropAnalyzerWithCustomTokenFilter() {
ClusterUpdateSettingsRequest request = analyze("DROP ANALYZER a3");
assertIsMarkedToBeRemove(request.persistentSettings(), ANALYZER.buildSettingName("a3"));
assertIsMarkedToBeRemove(request.persistentSettings(), TOKEN_FILTER.buildSettingName("a3_lowercase_german"));
}
use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class CreateAnalyzerTask method execute.
@Override
public void execute(BatchConsumer consumer, Row parameters) {
ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest();
request.persistentSettings(plan.createAnalyzerSettings());
OneRowActionListener<ClusterUpdateSettingsResponse> actionListener = new OneRowActionListener<>(consumer, TO_ONE_ROW);
transport.execute(request, actionListener);
}
use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class ESClusterUpdateSettingsTask method buildESUpdateClusterSettingRequest.
private ClusterUpdateSettingsRequest buildESUpdateClusterSettingRequest(Settings persistentSettings, Settings transientSettings) {
ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest();
request.persistentSettings(persistentSettings);
request.transientSettings(transientSettings);
if (plan.persistentSettingsToRemove() != null) {
request.persistentSettingsToRemove(plan.persistentSettingsToRemove());
}
if (plan.transientSettingsToRemove() != null) {
request.transientSettingsToRemove(plan.transientSettingsToRemove());
}
return request;
}
use of org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project elasticsearch by elastic.
the class RestClusterUpdateSettingsAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final ClusterUpdateSettingsRequest clusterUpdateSettingsRequest = Requests.clusterUpdateSettingsRequest();
clusterUpdateSettingsRequest.timeout(request.paramAsTime("timeout", clusterUpdateSettingsRequest.timeout()));
clusterUpdateSettingsRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterUpdateSettingsRequest.masterNodeTimeout()));
Map<String, Object> source;
try (XContentParser parser = request.contentParser()) {
source = parser.map();
}
if (source.containsKey("transient")) {
clusterUpdateSettingsRequest.transientSettings((Map) source.get("transient"));
}
if (source.containsKey("persistent")) {
clusterUpdateSettingsRequest.persistentSettings((Map) source.get("persistent"));
}
return channel -> client.admin().cluster().updateSettings(clusterUpdateSettingsRequest, new AcknowledgedRestListener<ClusterUpdateSettingsResponse>(channel) {
@Override
protected void addCustomFields(XContentBuilder builder, ClusterUpdateSettingsResponse response) throws IOException {
builder.startObject("persistent");
response.getPersistentSettings().toXContent(builder, request);
builder.endObject();
builder.startObject("transient");
response.getTransientSettings().toXContent(builder, request);
builder.endObject();
}
});
}
Aggregations