Search in sources :

Example 11 with ClusterUpdateSettingsRequest

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();
        }
    });
}
Also used : BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) Set(java.util.Set) IOException(java.io.IOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) RestController(org.elasticsearch.rest.RestController) XContentParser(org.elasticsearch.common.xcontent.XContentParser) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) Settings(org.elasticsearch.common.settings.Settings) Map(java.util.Map) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) Requests(org.elasticsearch.client.Requests) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener) IOException(java.io.IOException) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) XContentParser(org.elasticsearch.common.xcontent.XContentParser) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder)

Example 12 with ClusterUpdateSettingsRequest

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")));
}
Also used : ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) Test(org.junit.Test) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest)

Example 13 with ClusterUpdateSettingsRequest

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]")));
}
Also used : ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) Test(org.junit.Test) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest)

Example 14 with ClusterUpdateSettingsRequest

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")));
}
Also used : ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) Test(org.junit.Test) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest)

Example 15 with ClusterUpdateSettingsRequest

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"));
}
Also used : ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) Test(org.junit.Test) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest)

Aggregations

ClusterUpdateSettingsRequest (org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)22 Settings (org.elasticsearch.common.settings.Settings)10 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)9 Test (org.junit.Test)9 ClusterUpdateSettingsResponse (org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse)8 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)6 Row (io.crate.data.Row)5 Row1 (io.crate.data.Row1)5 RowConsumer (io.crate.data.RowConsumer)5 OneRowActionListener (io.crate.execution.support.OneRowActionListener)5 DependencyCarrier (io.crate.planner.DependencyCarrier)5 Plan (io.crate.planner.Plan)5 PlannerContext (io.crate.planner.PlannerContext)5 SubQueryResults (io.crate.planner.operators.SubQueryResults)5 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)4 Symbol (io.crate.expression.symbol.Symbol)4 Function (java.util.function.Function)4 FulltextAnalyzerResolver (io.crate.metadata.FulltextAnalyzerResolver)3 ANALYZER (io.crate.metadata.FulltextAnalyzerResolver.CustomType.ANALYZER)3 CHAR_FILTER (io.crate.metadata.FulltextAnalyzerResolver.CustomType.CHAR_FILTER)3