use of io.crate.analyze.AnalyzedCreateAnalyzer in project crate by crate.
the class CreateAnalyzerPlan method createRequest.
@VisibleForTesting
public static ClusterUpdateSettingsRequest createRequest(AnalyzedCreateAnalyzer createAnalyzer, CoordinatorTxnCtx txnCtx, NodeContext nodeCtx, Row parameters, SubQueryResults subQueryResults, FulltextAnalyzerResolver ftResolver) {
Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate(txnCtx, nodeCtx, x, parameters, subQueryResults);
var analyzerIdent = createAnalyzer.ident();
var tokenizer = bindTokenizer(createAnalyzer.tokenizer(), analyzerIdent, eval, ftResolver);
var tokenFilters = bindTokenFilters(createAnalyzer.tokenFilters(), analyzerIdent, eval, ftResolver);
var charFilters = bindCharFilters(createAnalyzer.charFilters(), analyzerIdent, eval, ftResolver);
var genericAnalyzerSettings = bindGenericAnalyzerProperties(createAnalyzer.genericAnalyzerProperties(), analyzerIdent, eval);
var analyzerSettings = buildAnalyzerSettings(analyzerIdent, createAnalyzer.extendedAnalyzerName(), tokenizer, tokenFilters, charFilters, genericAnalyzerSettings, ftResolver);
Settings.Builder encodedSettingsBuilder = Settings.builder();
encodedSettingsBuilder.put(ANALYZER.buildSettingName(analyzerIdent), encodeSettings(analyzerSettings).utf8ToString());
if (tokenizer != null && !tokenizer.v2().isEmpty()) {
encodedSettingsBuilder.put(TOKENIZER.buildSettingName(tokenizer.v1()), encodeSettings(tokenizer.v2()).utf8ToString());
}
for (Map.Entry<String, Settings> tokenFilter : tokenFilters.entrySet()) {
if (!tokenFilter.getValue().isEmpty()) {
encodedSettingsBuilder.put(TOKEN_FILTER.buildSettingName(tokenFilter.getKey()), encodeSettings(tokenFilter.getValue()).utf8ToString());
}
}
for (Map.Entry<String, Settings> charFilter : charFilters.entrySet()) {
if (!charFilter.getValue().isEmpty()) {
encodedSettingsBuilder.put(CHAR_FILTER.buildSettingName(charFilter.getKey()), encodeSettings(charFilter.getValue()).utf8ToString());
}
}
return new ClusterUpdateSettingsRequest().persistentSettings(encodedSettingsBuilder.build());
}
Aggregations