Search in sources :

Example 6 with ClusterUpdateSettingsRequest

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

Example 7 with ClusterUpdateSettingsRequest

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

Example 8 with ClusterUpdateSettingsRequest

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);
}
Also used : OneRowActionListener(io.crate.executor.transport.OneRowActionListener) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)

Example 9 with ClusterUpdateSettingsRequest

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;
}
Also used : ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)

Example 10 with ClusterUpdateSettingsRequest

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();
        }
    });
}
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)

Aggregations

ClusterUpdateSettingsRequest (org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)21 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)9 Settings (org.elasticsearch.common.settings.Settings)9 Test (org.junit.Test)9 ClusterUpdateSettingsResponse (org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse)7 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