Skip to content
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

Make FieldNameAnalyzer less lenient. #11141

Merged
merged 1 commit into from May 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -63,7 +63,9 @@ private Analyzer getAnalyzer(String name) {
if (analyzer != null) {
return analyzer;
}
return defaultAnalyzer;
// Don't be lenient here and return the default analyzer
// Fields need to be explicitly added
throw new IllegalArgumentException("Field [" + name + "] has no associated analyzer");
}

/**
Expand All @@ -72,9 +74,11 @@ private Analyzer getAnalyzer(String name) {
public FieldNameAnalyzer copyAndAddAll(Collection<? extends Map.Entry<String, Analyzer>> mappers) {
CopyOnWriteHashMap<String, Analyzer> analyzers = this.analyzers;
for (Map.Entry<String, Analyzer> entry : mappers) {
if (entry.getValue() != null) {
analyzers = analyzers.copyAndPut(entry.getKey(), entry.getValue());
Analyzer analyzer = entry.getValue();
if (analyzer == null) {
analyzer = defaultAnalyzer;
}
analyzers = analyzers.copyAndPut(entry.getKey(), analyzer);
}
return new FieldNameAnalyzer(analyzers, defaultAnalyzer);
}
Expand Down
Expand Up @@ -19,8 +19,6 @@

package org.elasticsearch.index.mapper;

import java.util.Objects;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.DelegatingAnalyzerWrapper;
import org.elasticsearch.index.analysis.FieldNameAnalyzer;
Expand Down