Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Root mapper analyzer/index_analyzer/search_analyzer with unregistered…

… analyzer name won't fail, closes #1389.
  • Loading branch information...
commit 1012f6a3ea0c3b3f18acbdce4e47b7f934d71e35 1 parent bb9d8fe
@kimchy kimchy authored
View
21 modules/elasticsearch/src/main/java/org/elasticsearch/index/mapper/DocumentMapperParser.java
@@ -33,6 +33,7 @@
import org.elasticsearch.index.AbstractIndexComponent;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.analysis.AnalysisService;
+import org.elasticsearch.index.analysis.NamedAnalyzer;
import org.elasticsearch.index.mapper.core.*;
import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper;
import org.elasticsearch.index.mapper.internal.*;
@@ -165,12 +166,24 @@ public DocumentMapper parse(@Nullable String type, String source, String default
Object fieldNode = entry.getValue();
if ("index_analyzer".equals(fieldName)) {
- docBuilder.indexAnalyzer(analysisService.analyzer(fieldNode.toString()));
+ NamedAnalyzer analyzer = analysisService.analyzer(fieldNode.toString());
+ if (analyzer == null) {
+ throw new MapperParsingException("Analyzer [" + fieldNode.toString() + "] not found for index_analyzer setting on root type [" + type + "]");
+ }
+ docBuilder.indexAnalyzer(analyzer);
} else if ("search_analyzer".equals(fieldName)) {
- docBuilder.searchAnalyzer(analysisService.analyzer(fieldNode.toString()));
+ NamedAnalyzer analyzer = analysisService.analyzer(fieldNode.toString());
+ if (analyzer == null) {
+ throw new MapperParsingException("Analyzer [" + fieldNode.toString() + "] not found for search_analyzer setting on root type [" + type + "]");
+ }
+ docBuilder.searchAnalyzer(analyzer);
} else if ("analyzer".equals(fieldName)) {
- docBuilder.indexAnalyzer(analysisService.analyzer(fieldNode.toString()));
- docBuilder.searchAnalyzer(analysisService.analyzer(fieldNode.toString()));
+ NamedAnalyzer analyzer = analysisService.analyzer(fieldNode.toString());
+ if (analyzer == null) {
+ throw new MapperParsingException("Analyzer [" + fieldNode.toString() + "] not found for analyzer setting on root type [" + type + "]");
+ }
+ docBuilder.indexAnalyzer(analyzer);
+ docBuilder.searchAnalyzer(analyzer);
} else {
Mapper.TypeParser typeParser = rootTypeParsers.get(fieldName);
if (typeParser != null) {
Please sign in to comment.
Something went wrong with that request. Please try again.