-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Remove unused parameters for AnalysisRegistry#processAnalyzerFactory #27232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,16 +18,12 @@ | |
| */ | ||
| package org.elasticsearch.index.analysis; | ||
|
|
||
| import org.apache.logging.log4j.Logger; | ||
| import org.apache.lucene.analysis.Analyzer; | ||
| import org.apache.lucene.util.IOUtils; | ||
| import org.elasticsearch.ElasticsearchException; | ||
| import org.elasticsearch.Version; | ||
| import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
| import org.elasticsearch.common.logging.DeprecationLogger; | ||
| import org.elasticsearch.common.logging.Loggers; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.common.util.set.Sets; | ||
| import org.elasticsearch.env.Environment; | ||
| import org.elasticsearch.index.Index; | ||
| import org.elasticsearch.index.IndexSettings; | ||
|
|
@@ -42,7 +38,6 @@ | |
| import java.util.HashMap; | ||
| import java.util.Locale; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
| import java.util.stream.Collectors; | ||
|
|
||
|
|
@@ -188,9 +183,9 @@ public Map<String, AnalyzerProvider<?>> buildAnalyzerFactories(IndexSettings ind | |
| } | ||
|
|
||
| public Map<String, AnalyzerProvider<?>> buildNormalizerFactories(IndexSettings indexSettings) throws IOException { | ||
| final Map<String, Settings> noralizersSettings = indexSettings.getSettings().getGroups("index.analysis.normalizer"); | ||
| final Map<String, Settings> normalizersSettings = indexSettings.getSettings().getGroups("index.analysis.normalizer"); | ||
| // TODO: Have pre-built normalizers | ||
| return buildMapping(Component.NORMALIZER, indexSettings, noralizersSettings, normalizers, Collections.emptyMap()); | ||
| return buildMapping(Component.NORMALIZER, indexSettings, normalizersSettings, normalizers, Collections.emptyMap()); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -455,33 +450,20 @@ public IndexAnalyzers build(IndexSettings indexSettings, | |
|
|
||
| Index index = indexSettings.getIndex(); | ||
| analyzerProviders = new HashMap<>(analyzerProviders); | ||
| Logger logger = Loggers.getLogger(getClass(), indexSettings.getSettings()); | ||
| DeprecationLogger deprecationLogger = new DeprecationLogger(logger); | ||
| Map<String, NamedAnalyzer> analyzerAliases = new HashMap<>(); | ||
| Map<String, NamedAnalyzer> analyzers = new HashMap<>(); | ||
| Map<String, NamedAnalyzer> normalizers = new HashMap<>(); | ||
| for (Map.Entry<String, AnalyzerProvider<?>> entry : analyzerProviders.entrySet()) { | ||
| processAnalyzerFactory(deprecationLogger, indexSettings, entry.getKey(), entry.getValue(), analyzerAliases, analyzers, | ||
| processAnalyzerFactory(indexSettings, entry.getKey(), entry.getValue(), analyzers, | ||
| tokenFilterFactoryFactories, charFilterFactoryFactories, tokenizerFactoryFactories); | ||
| } | ||
| for (Map.Entry<String, AnalyzerProvider<?>> entry : normalizerProviders.entrySet()) { | ||
| processNormalizerFactory(deprecationLogger, indexSettings, entry.getKey(), entry.getValue(), normalizers, | ||
| processNormalizerFactory(entry.getKey(), entry.getValue(), normalizers, | ||
| tokenizerFactoryFactories.get("keyword"), tokenFilterFactoryFactories, charFilterFactoryFactories); | ||
| } | ||
| for (Map.Entry<String, NamedAnalyzer> entry : analyzerAliases.entrySet()) { | ||
|
||
| String key = entry.getKey(); | ||
| if (analyzers.containsKey(key) && | ||
| ("default".equals(key) || "default_search".equals(key) || "default_search_quoted".equals(key)) == false) { | ||
| throw new IllegalStateException("already registered analyzer with name: " + key); | ||
| } else { | ||
| NamedAnalyzer configured = entry.getValue(); | ||
| analyzers.put(key, configured); | ||
| } | ||
| } | ||
|
|
||
| if (!analyzers.containsKey("default")) { | ||
| processAnalyzerFactory(deprecationLogger, indexSettings, "default", new StandardAnalyzerProvider(indexSettings, null, "default", Settings.Builder.EMPTY_SETTINGS), | ||
| analyzerAliases, analyzers, tokenFilterFactoryFactories, charFilterFactoryFactories, tokenizerFactoryFactories); | ||
| processAnalyzerFactory(indexSettings, "default", new StandardAnalyzerProvider(indexSettings, null, "default", Settings.Builder.EMPTY_SETTINGS), | ||
| analyzers, tokenFilterFactoryFactories, charFilterFactoryFactories, tokenizerFactoryFactories); | ||
| } | ||
| if (!analyzers.containsKey("default_search")) { | ||
| analyzers.put("default_search", analyzers.get("default")); | ||
|
|
@@ -490,16 +472,15 @@ public IndexAnalyzers build(IndexSettings indexSettings, | |
| analyzers.put("default_search_quoted", analyzers.get("default_search")); | ||
| } | ||
|
|
||
|
|
||
| NamedAnalyzer defaultAnalyzer = analyzers.get("default"); | ||
| if (defaultAnalyzer == null) { | ||
| throw new IllegalArgumentException("no default analyzer configured"); | ||
| } | ||
| if (analyzers.containsKey("default_index")) { | ||
| throw new IllegalArgumentException("setting [index.analysis.analyzer.default_index] is not supported anymore, use [index.analysis.analyzer.default] instead for index [" + index.getName() + "]"); | ||
| } | ||
| NamedAnalyzer defaultSearchAnalyzer = analyzers.containsKey("default_search") ? analyzers.get("default_search") : defaultAnalyzer; | ||
| NamedAnalyzer defaultSearchQuoteAnalyzer = analyzers.containsKey("default_search_quote") ? analyzers.get("default_search_quote") : defaultSearchAnalyzer; | ||
| NamedAnalyzer defaultSearchAnalyzer = analyzers.getOrDefault("default_search", defaultAnalyzer); | ||
| NamedAnalyzer defaultSearchQuoteAnalyzer = analyzers.getOrDefault("default_search_quote", defaultSearchAnalyzer); | ||
|
|
||
| for (Map.Entry<String, NamedAnalyzer> analyzer : analyzers.entrySet()) { | ||
| if (analyzer.getKey().startsWith("_")) { | ||
|
|
@@ -510,11 +491,9 @@ public IndexAnalyzers build(IndexSettings indexSettings, | |
| unmodifiableMap(analyzers), unmodifiableMap(normalizers)); | ||
| } | ||
|
|
||
| private void processAnalyzerFactory(DeprecationLogger deprecationLogger, | ||
| IndexSettings indexSettings, | ||
| private void processAnalyzerFactory(IndexSettings indexSettings, | ||
|
||
| String name, | ||
| AnalyzerProvider<?> analyzerFactory, | ||
| Map<String, NamedAnalyzer> analyzerAliases, | ||
| Map<String, NamedAnalyzer> analyzers, Map<String, TokenFilterFactory> tokenFilters, | ||
| Map<String, CharFilterFactory> charFilters, Map<String, TokenizerFactory> tokenizers) { | ||
| /* | ||
|
|
@@ -561,8 +540,7 @@ private void processAnalyzerFactory(DeprecationLogger deprecationLogger, | |
| } | ||
| } | ||
|
|
||
| private void processNormalizerFactory(DeprecationLogger deprecationLogger, | ||
| IndexSettings indexSettings, | ||
| private void processNormalizerFactory( | ||
| String name, | ||
| AnalyzerProvider<?> normalizerFactory, | ||
| Map<String, NamedAnalyzer> normalizers, | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix a typo.