use of org.graylog.shaded.elasticsearch7.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();
}
});
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class CreateAnalyzerAnalyzerTest method testCreateAnalyzerWithCharFilters.
@Test
public void testCreateAnalyzerWithCharFilters() throws Exception {
ClusterUpdateSettingsRequest request = analyze("CREATE ANALYZER a3 (" + " TOKENIZER lowercase," + " CHAR_FILTERS (" + " \"html_strip\"," + " my_mapping WITH (" + " type='mapping'," + " mappings=['ph=>f', 'ß=>ss', 'ö=>oe']" + " )" + " )" + ")");
assertThat(extractAnalyzerSettings("a3", request.persistentSettings()), allOf(hasEntry("index.analysis.analyzer.a3.tokenizer", "lowercase"), hasEntry("index.analysis.analyzer.a3.char_filter", "[html_strip, a3_my_mapping]")));
var charFiltersSettings = FulltextAnalyzerResolver.decodeSettings(request.persistentSettings().get(CHAR_FILTER.buildSettingName("a3_my_mapping")));
assertThat(charFiltersSettings, allOf(hasEntry("index.analysis.char_filter.a3_my_mapping.mappings", "[ph=>f, ß=>ss, ö=>oe]"), hasEntry("index.analysis.char_filter.a3_my_mapping.type", "mapping")));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class CreateAnalyzerAnalyzerTest method testCreateAnalyzerWithTokenFilters.
@Test
public void testCreateAnalyzerWithTokenFilters() throws Exception {
ClusterUpdateSettingsRequest request = analyze("CREATE ANALYZER a11 (" + " TOKENIZER standard," + " TOKEN_FILTERS (" + " lowercase," + " mystop WITH (" + " type='stop'," + " stopword=['the', 'over']" + " )" + " )" + ")");
assertThat(extractAnalyzerSettings("a11", request.persistentSettings()), allOf(hasEntry("index.analysis.analyzer.a11.tokenizer", "standard"), hasEntry("index.analysis.analyzer.a11.filter", "[lowercase, a11_mystop]")));
var tokenFiltersSettings = FulltextAnalyzerResolver.decodeSettings(request.persistentSettings().get(TOKEN_FILTER.buildSettingName("a11_mystop")));
assertThat(tokenFiltersSettings, allOf(hasEntry("index.analysis.filter.a11_mystop.type", "stop"), hasEntry("index.analysis.filter.a11_mystop.stopword", "[the, over]")));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class CreateAnalyzerAnalyzerTest method testCreateAnalyzerExtendingBuiltin.
@Test
public void testCreateAnalyzerExtendingBuiltin() throws Exception {
ClusterUpdateSettingsRequest request = analyze("CREATE ANALYZER a4 EXTENDS " + "german WITH (" + " \"stop_words\"=['der', 'die', 'das']" + ")");
assertThat(extractAnalyzerSettings("a4", request.persistentSettings()), allOf(hasEntry("index.analysis.analyzer.a4.stop_words", "[der, die, das]"), hasEntry("index.analysis.analyzer.a4.type", "german")));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest in project crate by crate.
the class DropAnalyzerTest method testDropAnalyzer.
@Test
public void testDropAnalyzer() {
ClusterUpdateSettingsRequest request = analyze("DROP ANALYZER a1");
assertIsMarkedToBeRemove(request.persistentSettings(), ANALYZER.buildSettingName("a1"));
}
Aggregations